Merge pull request #5870 from hashicorp/b-nmd-1529-alloc-stop-missing-header

api: return X-Nomad-Index header on allocation stop
This commit is contained in:
Chris Baker
2019-07-17 13:25:17 -04:00
committed by GitHub
3 changed files with 10 additions and 7 deletions

View File

@@ -335,9 +335,8 @@ func (a *Allocations) Signal(alloc *Allocation, q *QueryOptions, task, signal st
}
req := AllocSignalRequest{
AllocID: alloc.ID,
Signal: signal,
Task: task,
Signal: signal,
Task: task,
}
var resp GenericResponse
@@ -519,9 +518,8 @@ type AllocationRestartRequest struct {
}
type AllocSignalRequest struct {
AllocID string
Task string
Signal string
Task string
Signal string
}
// GenericResponse is used to respond to a request where no

View File

@@ -125,9 +125,11 @@ func (s *HTTPServer) allocStop(allocID string, resp http.ResponseWriter, req *ht
if structs.IsErrUnknownAllocation(rpcErr) {
rpcErr = CodedError(404, allocNotFoundErr)
}
return nil, rpcErr
}
return &out, rpcErr
setIndex(resp, out.Index)
return &out, nil
}
func (s *HTTPServer) ClientAllocRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {

View File

@@ -9,6 +9,7 @@ import (
"net/http/httptest"
"os"
"reflect"
"strconv"
"strings"
"testing"
@@ -419,6 +420,8 @@ func TestHTTP_AllocStop(t *testing.T) {
a := obj.(*structs.AllocStopResponse)
require.NotEmpty(a.EvalID, "missing eval")
require.NotEmpty(a.Index, "missing index")
headerIndex, _ := strconv.ParseUint(respW.Header().Get("X-Nomad-Index"), 10, 64)
require.Equal(a.Index, headerIndex)
}
// Test that we 404 when the allocid is invalid