From 35d90fc899d91541e7a715ddfac442fd7cbfd63c Mon Sep 17 00:00:00 2001 From: Pierre Souchay Date: Wed, 28 Aug 2019 21:57:05 +0200 Subject: [PATCH] Display IPs of machines when node names conflict to ease troubleshooting When there is an node name conflicts, such messages are displayed within Consul: `consul.fsm: EnsureRegistration failed: failed inserting node: Error while renaming Node ID: "e1d456bc-f72d-98e5-ebb3-26ae80d785cf": Node name node001 is reserved by node 05f10209-1b9c-b90c-e3e2-059e64556d4a with name node001` While it is easy to find the node that has reserved the name, it is hard to find the node trying to aquire the name since it is not registered, because it is not part of `consul members` output This PR will display the IP of the offender and solve far more easily those issues. --- agent/consul/state/catalog.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agent/consul/state/catalog.go b/agent/consul/state/catalog.go index 08f0b6dcb..7e7e89fb8 100644 --- a/agent/consul/state/catalog.go +++ b/agent/consul/state/catalog.go @@ -393,7 +393,7 @@ func (s *Store) ensureNoNodeWithSimilarNameTxn(tx *memdb.Txn, node *structs.Node } if !(enode.ID == "" && allowClashWithoutID) && nodeHealthy { - return fmt.Errorf("Node name %s is reserved by node %s with name %s", node.Node, enode.ID, enode.Node) + return fmt.Errorf("Node name %s is reserved by node %s with name %s (%s)", node.Node, enode.ID, enode.Node, enode.Address) } } } @@ -447,13 +447,13 @@ func (s *Store) ensureNodeTxn(tx *memdb.Txn, idx uint64, node *structs.Node) err // Lets first get all nodes and check whether name do match, we do not allow clash on nodes without ID dupNameError := s.ensureNoNodeWithSimilarNameTxn(tx, node, false) if dupNameError != nil { - return fmt.Errorf("Error while renaming Node ID: %q: %s", node.ID, dupNameError) + return fmt.Errorf("Error while renaming Node ID: %q (%s): %s", node.ID, node.Address, dupNameError) } // We are actually renaming a node, remove its reference first err := s.deleteNodeTxn(tx, idx, n.Node) if err != nil { - return fmt.Errorf("Error while renaming Node ID: %q from %s to %s", - node.ID, n.Node, node.Node) + return fmt.Errorf("Error while renaming Node ID: %q (%s) from %s to %s", + node.ID, node.Address, n.Node, node.Node) } } } else {