diff --git a/agent/consul/discoverychain/compile.go b/agent/consul/discoverychain/compile.go index 9bb5d2905d..f091f91b9f 100644 --- a/agent/consul/discoverychain/compile.go +++ b/agent/consul/discoverychain/compile.go @@ -554,7 +554,7 @@ func (c *compiler) assembleChain() error { dest := route.Destination svc := defaultIfEmpty(dest.Service, c.serviceName) - destNamespace := defaultIfEmpty(dest.Namespace, c.evaluateInNamespace) + destNamespace := defaultIfEmpty(dest.Namespace, router.NamespaceOrDefault()) // Check to see if the destination is eligible for splitting. var ( @@ -579,13 +579,13 @@ func (c *compiler) assembleChain() error { // If we have a router, we'll add a catch-all route at the end to send // unmatched traffic to the next hop in the chain. - defaultDestinationNode, err := c.getSplitterOrResolverNode(c.newTarget(c.serviceName, "", "", "")) + defaultDestinationNode, err := c.getSplitterOrResolverNode(c.newTarget(router.Name, "", router.NamespaceOrDefault(), "")) if err != nil { return err } defaultRoute := &structs.DiscoveryRoute{ - Definition: newDefaultServiceRoute(c.serviceName, c.evaluateInNamespace), + Definition: newDefaultServiceRoute(router.Name, router.NamespaceOrDefault()), NextNode: defaultDestinationNode.MapKey(), } routeNode.Routes = append(routeNode.Routes, defaultRoute) diff --git a/agent/service_manager_test.go b/agent/service_manager_test.go index cb38266018..7b211884e6 100644 --- a/agent/service_manager_test.go +++ b/agent/service_manager_test.go @@ -310,8 +310,10 @@ func TestServiceManager_PersistService_API(t *testing.T) { EnterpriseMeta: *structs.DefaultEnterpriseMeta(), } - svcFile := filepath.Join(a.Config.DataDir, servicesDir, stringHash(svc.ID)) - configFile := filepath.Join(a.Config.DataDir, serviceConfigDir, stringHash(svc.ID)) + svcID := svc.CompoundServiceID() + + svcFile := filepath.Join(a.Config.DataDir, servicesDir, svcID.StringHash()) + configFile := filepath.Join(a.Config.DataDir, serviceConfigDir, svcID.StringHash()) // Service is not persisted unless requested, but we always persist service configs. require.NoError(a.AddService(svc, nil, false, "", ConfigSourceRemote))