diff --git a/admiral/pkg/clusters/configwriter.go b/admiral/pkg/clusters/configwriter.go index 735f2057..2fc67634 100644 --- a/admiral/pkg/clusters/configwriter.go +++ b/admiral/pkg/clusters/configwriter.go @@ -178,7 +178,7 @@ func getServiceEntryEndpoints( for resourceType, _ := range identityConfigEnvironment.Type { // Rollout without weights is treated the same as deployment so sort and take first service // If any of the rolloutServicesMap have weights then add them to the list of endpointsMap - if resourceType == common.Rollout { + if resourceType == common.Rollout && len(rolloutServicesMap) > 0 { ep := tmpEp.DeepCopy() if clientCluster == serverCluster { if identityConfigEnvironment.Type[resourceType].Strategy == canaryStrategy { @@ -219,7 +219,7 @@ func getServiceEntryEndpoints( if !endpointFromRollout || resourceType == common.Deployment { tmpEpCopy := tmpEp.DeepCopy() if clientCluster == serverCluster { - if resourceType == common.Rollout { + if resourceType == common.Rollout && len(rolloutServicesMap) > 0 { if _, ok := rolloutServicesMap[rootServiceKey]; ok { tmpEpCopy.Address = rolloutServicesMap[rootServiceKey].Name + common.Sep + identityConfigEnvironment.Namespace + common.GetLocalDomainSuffix() } else { @@ -227,7 +227,7 @@ func getServiceEntryEndpoints( } tmpEpCopy.Ports = rolloutServices[0].Ports } - if resourceType == common.Deployment { + if resourceType == common.Deployment && len(deploymentServicesMap) > 0 { tmpEpCopy.Address = deploymentServices[0].Name + common.Sep + identityConfigEnvironment.Namespace + common.GetLocalDomainSuffix() tmpEpCopy.Ports = deploymentServices[0].Ports } diff --git a/admiral/pkg/registry/testdata/sampleIdentityConfiguration.json b/admiral/pkg/registry/testdata/sampleIdentityConfiguration.json index c0dbf437..88cd74ef 100644 --- a/admiral/pkg/registry/testdata/sampleIdentityConfiguration.json +++ b/admiral/pkg/registry/testdata/sampleIdentityConfiguration.json @@ -15,11 +15,14 @@ "namespace": "ns-1-usw2-prf", "serviceName": "app-1-spk-root-service", "services": { - "app-1-spk-root-service": { + "root": { "name": "app-1-spk-root-service", "weight": -1, "ports": { "http": 8090 + }, + "selectors": { + "app": "app1" } } }, @@ -114,11 +117,14 @@ "namespace": "ns-1-usw2-e2e", "serviceName": "app-1-spk-root-service", "services": { - "app-1-spk-root-service": { + "root": { "name": "app-1-spk-root-service", "weight": -1, "ports": { "http": 8090 + }, + "selectors": { + "app": "app1" } } }, @@ -213,11 +219,14 @@ "namespace": "ns-1-usw2-qal", "serviceName": "app-1-spk-root-service", "services": { - "app-1-spk-root-service": { + "root": { "name": "app-1-spk-root-service", "weight": -1, "ports": { "http": 8090 + }, + "selectors": { + "app": "app1" } } },