consul/agent/consul
Pierre Souchay ef3b81ab13 Allow to rename nodes with IDs, will fix #3974 and #4413 (#4415)
* Allow to rename nodes with IDs, will fix #3974 and #4413

This change allow to rename any well behaving recent agent with an
ID to be renamed safely, ie: without taking the name of another one
with case insensitive comparison.

Deprecated behaviour warning
----------------------------

Due to asceding compatibility, it is still possible however to
"take" the name of another name by not providing any ID.

Note that when not providing any ID, it is possible to have 2 nodes
having similar names with case differences, ie: myNode and mynode
which might lead to DB corruption on Consul server side and
lead to server not properly restarting.

See #3983 and #4399 for Context about this change.

Disabling registration of nodes without IDs as specified in #4414
should probably be the way to go eventually.

* Removed the case-insensitive search when adding a node within the else
block since it breaks the test TestAgentAntiEntropy_Services

While the else case is probably legit, it will be fixed with #4414 in
a later release.

* Added again the test in the else to avoid duplicated names, but
enforce this test only for nodes having IDs.

Thus most tests without any ID will work, and allows us fixing

* Added more tests regarding request with/without IDs.

`TestStateStore_EnsureNode` now test registration and renaming with IDs

`TestStateStore_EnsureNodeDeprecated` tests registration without IDs
and tests removing an ID from a node as well as updated a node
without its ID (deprecated behaviour kept for backwards compatibility)

* Do not allow renaming in case of conflict, including when other node has no ID

* Fixed function GetNodeID that was not working due to wrong type when searching node from its ID

Thus, all tests about renaming were not working properly.

Added the full test cas that allowed me to detect it.

* Better error messages, more tests when nodeID is not a valid UUID in GetNodeID()

* Added separate TestStateStore_GetNodeID to test GetNodeID.

More complete test coverage for GetNodeID

* Added new unit test `TestStateStore_ensureNoNodeWithSimilarNameTxn`

Also fixed comments to be clearer after remarks from @banks

* Fixed error message in unit test to match test case

* Use uuid.ParseUUID to parse Node.ID as requested by @mkeeler
2018-08-10 11:30:45 -04:00
..
autopilot Improve autopilot shutdown to be idempotent 2018-02-20 15:51:59 -08:00
fsm connect: add provider state to snapshots 2018-07-11 11:34:49 -07:00
prepared_query Allow ignoring checks by ID when defining a PreparedQuery. Fixes #3727. 2018-04-10 14:04:16 +01:00
state Allow to rename nodes with IDs, will fix #3974 and #4413 (#4415) 2018-08-10 11:30:45 -04:00
acl.go Updated swith case to use same branch for async-cache and extend-cache 2018-07-02 17:39:34 +02:00
acl_endpoint.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
acl_endpoint_test.go acl: consolidate error handling (#3401) 2017-08-23 16:52:48 +02:00
acl_replication.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
acl_replication_test.go BUGFIX: Unit test relying on WaitForLeader() did not work due to wrong test (#4472) 2018-08-06 19:46:09 -04:00
acl_test.go BUGFIX: Unit test relying on WaitForLeader() did not work due to wrong test (#4472) 2018-08-06 19:46:09 -04:00
autopilot.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
autopilot_oss.go Fix vet error 2017-12-18 18:04:42 -08:00
autopilot_test.go BUGFIX: Unit test relying on WaitForLeader() did not work due to wrong test (#4472) 2018-08-06 19:46:09 -04:00
catalog_endpoint.go Revert PR 4294 - Catalog Register: Generate UUID for services registered without one 2018-07-12 10:06:50 -04:00
catalog_endpoint_test.go Revert PR 4294 - Catalog Register: Generate UUID for services registered without one 2018-07-12 10:06:50 -04:00
client.go Fixup formatting 2018-07-12 10:14:26 -04:00
client_serf.go Allow for easy enterprise/oss coexistence 2018-05-24 10:36:42 -04:00
client_test.go Add a Client ReloadConfig test 2018-06-11 16:23:51 -04:00
config.go connect/ca: add configurable leaf cert TTL 2018-07-16 13:33:37 -07:00
connect_ca_endpoint.go Fixes #4421: General solution to stop blocking queries with index 0 (#4437) 2018-07-25 20:26:27 +01:00
connect_ca_endpoint_test.go fix inconsistency in TestConnectCAConfig_GetSet 2018-07-26 07:46:47 -07:00
consul_ca_delegate.go Move connect CA provider to separate package 2018-06-14 09:42:15 -07:00
coordinate_endpoint.go Fill out the tests around coordinate/node functionality 2017-10-31 15:36:44 -07:00
coordinate_endpoint_test.go Fill out the tests around coordinate/node functionality 2017-10-31 15:36:44 -07:00
enterprise_client_oss.go Allow for easy enterprise/oss coexistence 2018-05-24 10:36:42 -04:00
enterprise_server_oss.go Allow for easy enterprise/oss coexistence 2018-05-24 10:36:42 -04:00
filter.go Revert "Return 403 rather than a 404 when acls cause all results to be filter…" 2017-08-09 15:06:57 -07:00
filter_test.go Introduce Code Policy validation via sentinel, with a noop implementation 2017-09-25 13:44:55 -05:00
flood.go Add segment addr field to tags for LAN flood joiner 2017-08-30 11:58:29 -07:00
health_endpoint.go agent: address PR feedback 2018-06-14 09:41:49 -07:00
health_endpoint_test.go agent/consul: Health.ServiceNodes ACL check for Connect 2018-06-14 09:41:49 -07:00
helper_test.go Cleans up some drift between the OSS and Enterprise trees. 2017-10-11 15:53:07 -07:00
intention_endpoint.go agent/consul: set precedence value on struct itself 2018-06-25 12:24:16 -07:00
intention_endpoint_test.go agent/consul: set precedence value on struct itself 2018-06-25 12:24:16 -07:00
internal_endpoint.go Allows disabling WAN federation by setting serf WAN port to -1 2018-03-26 14:21:06 -05:00
internal_endpoint_test.go acl: consolidate error handling (#3401) 2017-08-23 16:52:48 +02:00
issue_test.go Moves the FSM into its own package. 2017-11-29 18:36:53 -08:00
kvs_endpoint.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
kvs_endpoint_test.go Replace time.Now().Sub(x) with time.Since(x) 2017-10-17 20:38:24 +02:00
leader.go connect/ca: check LeafCertTTL when rotating expired roots 2018-07-20 16:04:04 -07:00
leader_test.go Revert "CA initialization while boostrapping and TestLeader_ChangeServerID fix." (#4497) 2018-08-07 08:29:48 -04:00
merge.go Takes the skip out of the client check. 2017-09-06 17:05:40 -07:00
merge_test.go Skips unique node ID check for old versions of Consul. 2017-09-05 22:57:29 -07:00
operator_autopilot_endpoint.go Move autopilot to a standalone package 2017-12-11 16:45:33 -08:00
operator_autopilot_endpoint_test.go Move autopilot to a standalone package 2017-12-11 16:45:33 -08:00
operator_endpoint.go pkg refactor 2017-06-10 18:52:45 +02:00
operator_raft_endpoint.go Move autopilot to a standalone package 2017-12-11 16:45:33 -08:00
operator_raft_endpoint_test.go Removes bogus getPort() in favor of freeport. 2017-11-08 19:55:50 -08:00
prepared_query_endpoint.go agent/consul: support a Connect option on prepared query request 2018-06-25 12:24:12 -07:00
prepared_query_endpoint_test.go PR to fix TestAgent_IndexChurn and TestPreparedQuery_Wrapper. (#4512) 2018-08-09 12:40:07 -04:00
raft_rpc.go agent: move conn pool for muxed connections into separate pkg 2017-06-21 05:42:39 +02:00
rpc.go Fixes #4421: General solution to stop blocking queries with index 0 (#4437) 2018-07-25 20:26:27 +01:00
rpc_test.go Fixes #4421: General solution to stop blocking queries with index 0 (#4437) 2018-07-25 20:26:27 +01:00
rtt.go Added Coordinate.Node rpc endpoint and client api method 2017-10-26 19:16:40 -07:00
rtt_test.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
segment_oss.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
serf_test.go pkg refactor 2017-06-10 18:52:45 +02:00
server.go consul: Update buffer sizes 2018-08-08 10:26:58 -07:00
server_lookup.go More cleanup from code review 2017-08-30 12:31:36 -05:00
server_lookup_test.go More cleanup from code review 2017-08-30 12:31:36 -05:00
server_oss.go agent/consul: RPC endpoints to list roots 2018-06-14 09:41:50 -07:00
server_serf.go Allow for easy enterprise/oss coexistence 2018-05-24 10:36:42 -04:00
server_test.go Ooops remove the CA stuff from actual server defaults and make it test server only 2018-06-14 09:42:16 -07:00
session_endpoint.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
session_endpoint_test.go BUGFIX: Unit test relying on WaitForLeader() did not work due to wrong test (#4472) 2018-08-06 19:46:09 -04:00
session_timers.go address review comments 2017-07-07 09:22:34 +02:00
session_timers_test.go rpc: refactor sessionTimers and fix racy tests 2017-07-07 09:22:34 +02:00
session_ttl.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
session_ttl_test.go Moves the FSM into its own package. 2017-11-29 18:36:53 -08:00
snapshot_endpoint.go acl: consolidate error handling (#3401) 2017-08-23 16:52:48 +02:00
snapshot_endpoint_test.go Cleans up some edge cases in TestSnapshot_Forward_Leader. 2017-09-26 14:07:28 -07:00
stats_fetcher.go More refactoring to make autopilot consul-agnostic 2017-12-12 17:46:28 -08:00
stats_fetcher_test.go More refactoring to make autopilot consul-agnostic 2017-12-12 17:46:28 -08:00
status_endpoint.go Move autopilot to a standalone package 2017-12-11 16:45:33 -08:00
status_endpoint_test.go rpc: run agent/consul tests in parallel 2017-07-07 09:22:34 +02:00
txn_endpoint.go Remove deprecated metric names 2018-05-08 16:23:15 -07:00
txn_endpoint_test.go acl: consolidate error handling (#3401) 2017-08-23 16:52:48 +02:00
util.go remove golint warnings 2018-01-28 22:40:13 +04:00
util_test.go pkg refactor 2017-06-10 18:52:45 +02:00