diff --git a/agent/consul/internal_endpoint.go b/agent/consul/internal_endpoint.go index 31a084c79f..0a9ea16f2c 100644 --- a/agent/consul/internal_endpoint.go +++ b/agent/consul/internal_endpoint.go @@ -414,8 +414,15 @@ func (m *Internal) GatewayServices(args *structs.ServiceSpecificRequest, reply * } } + // We log a warning here to indicate that there is a potential + // misconfiguration. We explicitly do NOT return an error because this + // can occur in the course of normal operation by deleting a + // configuration entry or starting the proxy before registering the + // config entry. if !found { - return fmt.Errorf("service %q is not a configured terminating-gateway or ingress-gateway", args.ServiceName) + m.logger.Warn("no terminating-gateway or ingress-gateway associated with this gateway", + "gateway", args.ServiceName, + ) } index, services, err = state.GatewayServices(ws, args.ServiceName, &args.EnterpriseMeta) diff --git a/agent/consul/internal_endpoint_test.go b/agent/consul/internal_endpoint_test.go index a88e3f98a6..b49a9d5682 100644 --- a/agent/consul/internal_endpoint_test.go +++ b/agent/consul/internal_endpoint_test.go @@ -954,8 +954,11 @@ func TestInternal_GatewayServices_BothGateways(t *testing.T) { } var resp structs.IndexedGatewayServices err := msgpackrpc.CallWithCodec(codec, "Internal.GatewayServices", &req, &resp) - assert.Error(t, err) - assert.Contains(t, err.Error(), `service "api" is not a configured terminating-gateway or ingress-gateway`) + assert.NoError(t, err) + assert.Empty(t, resp.Services) + // Ensure that the index is not zero so that a blocking query still gets the + // latest GatewayServices index + assert.NotEqual(t, 0, resp.Index) } func TestInternal_GatewayServices_ACLFiltering(t *testing.T) { diff --git a/agent/proxycfg/manager.go b/agent/proxycfg/manager.go index 41dd77361e..7d8163f924 100644 --- a/agent/proxycfg/manager.go +++ b/agent/proxycfg/manager.go @@ -188,7 +188,7 @@ func (m *Manager) ensureProxyServiceLocked(ns *structs.NodeService, token string } // Set the necessary dependencies - state.logger = m.Logger + state.logger = m.Logger.With("service_id", sid.String()) state.cache = m.Cache state.source = m.Source state.dnsConfig = m.DNSConfig