Clarify node removal error when self-removing

Currently, if you issue a node removal from the node that is being
removed, then you will see a "node cannot be removed error". It's
not clear why you aren't able to remove the node. The error message
has been updated to clarify why.
This commit is contained in:
Ben Johnson 2021-02-16 14:52:49 -07:00
parent e724ad53f2
commit 841208858f
2 changed files with 3 additions and 3 deletions

2
api.go
View file

@ -1775,7 +1775,7 @@ func (api *API) RemoveNode(id string) (*topology.Node, error) {
}
if api.cluster.disCo.ID() == id {
return nil, errors.Wrapf(ErrPreconditionFailed, "the node %s can not be removed", id)
return nil, errors.Wrapf(ErrPreconditionFailed, "cannot issue node removal request to the node being removed, id=%s", id)
}
removeNode := api.cluster.nodeByID(id)

View file

@ -588,7 +588,7 @@ func TestClusterResize_RemoveNode(t *testing.T) {
nodeID := mustNodeID(coord.URL())
resp := test.Do(t, "POST", coord.URL()+"/cluster/resize/remove-node", fmt.Sprintf(`{"id": "%s"}`, nodeID))
expBody := fmt.Sprintf("removing node: the node %s can not be removed: precondition failed", nodeID)
expBody := fmt.Sprintf("removing node: cannot issue node removal request to the node being removed, id=%s: precondition failed", nodeID)
if resp.StatusCode != http.StatusInternalServerError {
t.Fatalf("expected StatusCode %d but got %d", http.StatusInternalServerError, resp.StatusCode)
} else if strings.TrimSpace(resp.Body) != expBody {
@ -600,7 +600,7 @@ func TestClusterResize_RemoveNode(t *testing.T) {
nodeID := mustNodeID(other.URL())
resp := test.Do(t, "POST", other.URL()+"/cluster/resize/remove-node", fmt.Sprintf(`{"id": "%s"}`, nodeID))
expBody := fmt.Sprintf("removing node: the node %s can not be removed: precondition failed", nodeID)
expBody := fmt.Sprintf(`removing node: cannot issue node removal request to the node being removed, id=%s: precondition failed`, nodeID)
if resp.StatusCode != http.StatusInternalServerError {
t.Fatalf("expected StatusCode %d but got %d", http.StatusInternalServerError, resp.StatusCode)
} else if strings.TrimSpace(resp.Body) != expBody {