Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update identity cluster cache when instances are found #252

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions admiral/pkg/clusters/serviceentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s
var serviceInstance *k8sV1.Service
var weightedServices map[string]*WeightedService
var rollout *argo.Rollout
var deployment *k8sAppsV1.Deployment
var gtps = make(map[string][]*v1.GlobalTrafficPolicy)

var namespace string
Expand All @@ -94,14 +95,21 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s

rc := remoteRegistry.GetRemoteController(clusterId)

deployment := rc.DeploymentController.Cache.Get(sourceIdentity, env)
if rc == nil {
log.Warnf(LogFormat, "Find", "remote-controller", clusterId, clusterId, "remote controller not available/initialized for the cluster")
continue
}

if rc.DeploymentController != nil {
deployment = rc.DeploymentController.Cache.Get(sourceIdentity, env)
}

if rc.RolloutController != nil {
rollout = rc.RolloutController.Cache.Get(sourceIdentity, env)
}

if deployment != nil {

remoteRegistry.AdmiralCache.IdentityClusterCache.Put(sourceIdentity, rc.ClusterID, rc.ClusterID)
serviceInstance = getServiceForDeployment(rc, deployment)
if serviceInstance == nil {
continue
Expand All @@ -113,7 +121,7 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s
sourceDeployments[rc.ClusterID] = deployment
createServiceEntry(event, rc, remoteRegistry.AdmiralCache, localMeshPorts, deployment, serviceEntries)
} else if rollout != nil {

remoteRegistry.AdmiralCache.IdentityClusterCache.Put(sourceIdentity, rc.ClusterID, rc.ClusterID)
weightedServices = getServiceForRollout(rc, rollout)
if len(weightedServices) == 0 {
continue
Expand Down Expand Up @@ -145,7 +153,6 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s
log.Debugf("No GTPs found for identity=%s in env=%s namespace=%s with key=%s", sourceIdentity, env, namespace, gtpKey)
}

remoteRegistry.AdmiralCache.IdentityClusterCache.Put(sourceIdentity, rc.ClusterID, rc.ClusterID)
remoteRegistry.AdmiralCache.CnameClusterCache.Put(cname, rc.ClusterID, rc.ClusterID)
remoteRegistry.AdmiralCache.CnameIdentityCache.Store(cname, sourceIdentity)
sourceServices[rc.ClusterID] = serviceInstance
Expand Down