Merge pull request #5960 from shvar/master
take NodeID from url in api for node eligibility
This commit is contained in:
commit
47e725011f
|
@ -166,6 +166,10 @@ func (s *HTTPServer) nodeToggleEligibility(resp http.ResponseWriter, req *http.R
|
|||
if err := decodeBody(req, &eligibilityRequest); err != nil {
|
||||
return nil, CodedError(400, err.Error())
|
||||
}
|
||||
if eligibilityRequest.NodeID == "" {
|
||||
eligibilityRequest.NodeID = nodeID
|
||||
}
|
||||
|
||||
s.parseWriteRequest(req, &eligibilityRequest.WriteRequest)
|
||||
|
||||
var out structs.NodeEligibilityUpdateResponse
|
||||
|
|
|
@ -370,13 +370,12 @@ func TestHTTP_NodeEligible(t *testing.T) {
|
|||
var resp structs.NodeUpdateResponse
|
||||
require.Nil(s.Agent.RPC("Node.Register", &args, &resp))
|
||||
|
||||
drainReq := api.NodeUpdateEligibilityRequest{
|
||||
NodeID: node.ID,
|
||||
eligibilityReq := api.NodeUpdateEligibilityRequest{
|
||||
Eligibility: structs.NodeSchedulingIneligible,
|
||||
}
|
||||
|
||||
// Make the HTTP request
|
||||
buf := encodeReq(drainReq)
|
||||
buf := encodeReq(eligibilityReq)
|
||||
req, err := http.NewRequest("POST", "/v1/node/"+node.ID+"/eligibility", buf)
|
||||
require.Nil(err)
|
||||
respW := httptest.NewRecorder()
|
||||
|
@ -399,8 +398,8 @@ func TestHTTP_NodeEligible(t *testing.T) {
|
|||
require.Equal(structs.NodeSchedulingIneligible, out.SchedulingEligibility)
|
||||
|
||||
// Make the HTTP request to set something invalid
|
||||
drainReq.Eligibility = "foo"
|
||||
buf = encodeReq(drainReq)
|
||||
eligibilityReq.Eligibility = "foo"
|
||||
buf = encodeReq(eligibilityReq)
|
||||
req, err = http.NewRequest("POST", "/v1/node/"+node.ID+"/eligibility", buf)
|
||||
require.Nil(err)
|
||||
respW = httptest.NewRecorder()
|
||||
|
|
Loading…
Reference in New Issue