diff --git a/agent/consul/catalog_endpoint.go b/agent/consul/catalog_endpoint.go index 840b97fa6a..adde8e52eb 100644 --- a/agent/consul/catalog_endpoint.go +++ b/agent/consul/catalog_endpoint.go @@ -47,17 +47,6 @@ func (c *Catalog) Register(args *structs.RegisterRequest, reply *struct{}) error // Handle a service registration. if args.Service != nil { - // Connect proxy specific logic - if args.Service.Kind == structs.ServiceKindConnectProxy { - // Name is optional, if it isn't set, we default to the - // proxy name. It actually MUST be this, but the validation - // below this will verify. - if args.Service.Service == "" { - args.Service.Service = fmt.Sprintf( - "%s-connect-proxy", args.Service.ProxyDestination) - } - } - // Validate the service. This is in addition to the below since // the above just hasn't been moved over yet. We should move it over // in time. diff --git a/agent/consul/catalog_endpoint_test.go b/agent/consul/catalog_endpoint_test.go index b095c3f3a8..fd437c9780 100644 --- a/agent/consul/catalog_endpoint_test.go +++ b/agent/consul/catalog_endpoint_test.go @@ -384,36 +384,6 @@ func TestCatalog_Register_ConnectProxy_invalid(t *testing.T) { assert.Contains(err.Error(), "ProxyDestination") } -// Test registering a proxy with no name set, which should work. -func TestCatalog_Register_ConnectProxy_noName(t *testing.T) { - t.Parallel() - - assert := assert.New(t) - dir1, s1 := testServer(t) - defer os.RemoveAll(dir1) - defer s1.Shutdown() - codec := rpcClient(t, s1) - defer codec.Close() - - args := structs.TestRegisterRequestProxy(t) - args.Service.Service = "" - - // Register - var out struct{} - assert.Nil(msgpackrpc.CallWithCodec(codec, "Catalog.Register", &args, &out)) - - // List - req := structs.ServiceSpecificRequest{ - Datacenter: "dc1", - ServiceName: fmt.Sprintf("%s-connect-proxy", args.Service.ProxyDestination), - } - var resp structs.IndexedServiceNodes - assert.Nil(msgpackrpc.CallWithCodec(codec, "Catalog.ServiceNodes", &req, &resp)) - assert.Len(resp.ServiceNodes, 1) - v := resp.ServiceNodes[0] - assert.Equal(structs.ServiceKindConnectProxy, v.ServiceKind) -} - // Test that write is required for the proxy destination to register a proxy. func TestCatalog_Register_ConnectProxy_ACLProxyDestination(t *testing.T) { t.Parallel() diff --git a/agent/structs/structs.go b/agent/structs/structs.go index f8f339a5b0..40b606d170 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -462,8 +462,11 @@ type ServiceNodes []*ServiceNode type ServiceKind string const ( - // ServiceKindTypical is a typical, classic Consul service. - ServiceKindTypical ServiceKind = "typical" + // ServiceKindTypical is a typical, classic Consul service. This is + // represented by the absense of a value. This was chosen for ease of + // backwards compatibility: existing services in the catalog would + // default to the typical service. + ServiceKindTypical ServiceKind = "" // ServiceKindConnectProxy is a proxy for the Connect feature. This // service proxies another service within Consul and speaks the connect