mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 19:05:42 +03:00
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:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user