From 841208858ffca739178787e67c93718d4e7cf01d Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 16 Feb 2021 14:52:49 -0700 Subject: [PATCH] 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. --- api.go | 2 +- server/cluster_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index f03c3f4d3..1cdbb004a 100644 --- a/api.go +++ b/api.go @@ -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) diff --git a/server/cluster_test.go b/server/cluster_test.go index 0239cbbc8..dba6c78f6 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -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 {