From 3807e04de9f9a7de9590f8d2cb25722632834bfc Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Thu, 12 Jul 2018 10:05:20 -0400 Subject: [PATCH 1/2] Revert PR 4294 - Catalog Register: Generate UUID for services registered without one UUID auto-generation here causes trouble in a few cases. The biggest being older nodes reregistering will fail when the UUIDs are different and the names match This reverts commit 0f700340828f464449c2e0d5a82db0bc5456d385. This reverts commit d1a8f9cb3f6f48dd9c8d0bc858031ff6ccff51d0. This reverts commit cf69ec42a418ab6594a6654e9545e12160f30970. --- agent/consul/catalog_endpoint.go | 7 ------ agent/consul/catalog_endpoint_test.go | 31 --------------------------- agent/consul/client.go | 2 +- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/agent/consul/catalog_endpoint.go b/agent/consul/catalog_endpoint.go index cc1e187e0f..a31ca59ebb 100644 --- a/agent/consul/catalog_endpoint.go +++ b/agent/consul/catalog_endpoint.go @@ -37,13 +37,6 @@ func (c *Catalog) Register(args *structs.RegisterRequest, reply *struct{}) error if _, err := uuid.ParseUUID(string(args.ID)); err != nil { return fmt.Errorf("Bad node ID: %v", err) } - } else { - id, err := uuid.GenerateUUID() - if err != nil { - return fmt.Errorf("Failed to generate ID: %v", err) - } - - args.ID = types.NodeID(id) } // Fetch the ACL token, if any. diff --git a/agent/consul/catalog_endpoint_test.go b/agent/consul/catalog_endpoint_test.go index 8564554629..7873fb7452 100644 --- a/agent/consul/catalog_endpoint_test.go +++ b/agent/consul/catalog_endpoint_test.go @@ -50,37 +50,6 @@ func TestCatalog_Register(t *testing.T) { } } -func TestCatalog_RegisterNoID(t *testing.T) { - t.Parallel() - dir1, s1 := testServer(t) - defer os.RemoveAll(dir1) - defer s1.Shutdown() - codec := rpcClient(t, s1) - defer codec.Close() - - arg := structs.RegisterRequest{ - Datacenter: "dc1", - Node: "foo", - Address: "127.0.0.1", - Service: &structs.NodeService{ - Service: "db", - Tags: []string{"master"}, - Port: 8000, - }, - } - var out struct{} - - require.NoError(t, msgpackrpc.CallWithCodec(codec, "Catalog.Register", &arg, &out)) - - var ns structs.IndexedNodeServices - nodeArgs := structs.NodeSpecificRequest{ - Datacenter: "dc1", - Node: "foo", - } - require.NoError(t, msgpackrpc.CallWithCodec(codec, "Catalog.NodeServices", &nodeArgs, &ns)) - require.NotEqual(t, types.NodeID(""), ns.NodeServices.Node.ID) -} - func TestCatalog_RegisterService_InvalidAddress(t *testing.T) { t.Parallel() dir1, s1 := testServer(t) diff --git a/agent/consul/client.go b/agent/consul/client.go index f6b123a315..000cb66f88 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -134,7 +134,7 @@ func NewClientLogger(config *Config, logger *log.Logger) (*Client, error) { shutdownCh: make(chan struct{}), } - c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst)) + c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst)) if err := c.initEnterprise(); err != nil { c.Shutdown() From 91150cca59784619d158e33068e096dee8757109 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Thu, 12 Jul 2018 10:14:26 -0400 Subject: [PATCH 2/2] Fixup formatting --- agent/consul/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/consul/client.go b/agent/consul/client.go index 000cb66f88..f6b123a315 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -134,7 +134,7 @@ func NewClientLogger(config *Config, logger *log.Logger) (*Client, error) { shutdownCh: make(chan struct{}), } - c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst)) + c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst)) if err := c.initEnterprise(); err != nil { c.Shutdown()