From 8a0488a8ef4b8437df91520e41e6aa187ce167f8 Mon Sep 17 00:00:00 2001 From: Nandan B N Date: Fri, 4 Mar 2022 18:25:14 +0530 Subject: [PATCH] fix panic: argoRolloutsEnabled=false --- admiral/pkg/clusters/types.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/admiral/pkg/clusters/types.go b/admiral/pkg/clusters/types.go index 72fabbc30..1fead796e 100644 --- a/admiral/pkg/clusters/types.go +++ b/admiral/pkg/clusters/types.go @@ -276,7 +276,9 @@ func (gtp *GlobalTrafficHandler) Added(obj *v1.GlobalTrafficPolicy) { //IMPORTANT: The deployment/Rollout matched with a GTP will not necessarily be from the same cluster. This is because the same service could be deployed in multiple clusters and we need to guarantee consistent behavior for _, remoteCluster := range gtp.RemoteRegistry.RemoteControllers { matchedDeployments = append(matchedDeployments, remoteCluster.DeploymentController.GetDeploymentByLabel(obj.Labels[common.GetGlobalTrafficDeploymentLabel()], obj.Namespace)...) - matchedRollouts = append(matchedRollouts, remoteCluster.RolloutController.GetRolloutByLabel(obj.Labels[common.GetGlobalTrafficDeploymentLabel()], obj.Namespace)...) + if gtp.RemoteRegistry.AdmiralCache.argoRolloutsEnabled { + matchedRollouts = append(matchedRollouts, remoteCluster.RolloutController.GetRolloutByLabel(obj.Labels[common.GetGlobalTrafficDeploymentLabel()], obj.Namespace)...) + } } deployments := common.MatchDeploymentsToGTP(obj, matchedDeployments) @@ -317,7 +319,9 @@ func (gtp *GlobalTrafficHandler) Updated(obj *v1.GlobalTrafficPolicy) { //IMPORTANT: The deployment/Rollout matched with a GTP will not necessarily be from the same cluster. This is because the same service could be deployed in multiple clusters and we need to guarantee consistent behavior for _, remoteCluster := range gtp.RemoteRegistry.RemoteControllers { matchedDeployments = append(matchedDeployments, remoteCluster.DeploymentController.GetDeploymentByLabel(obj.Labels[common.GetGlobalTrafficDeploymentLabel()], obj.Namespace)...) - matchedRollouts = append(matchedRollouts, remoteCluster.RolloutController.GetRolloutByLabel(obj.Labels[common.GetGlobalTrafficDeploymentLabel()], obj.Namespace)...) + if gtp.RemoteRegistry.AdmiralCache.argoRolloutsEnabled { + matchedRollouts = append(matchedRollouts, remoteCluster.RolloutController.GetRolloutByLabel(obj.Labels[common.GetGlobalTrafficDeploymentLabel()], obj.Namespace)...) + } } deployments := common.MatchDeploymentsToGTP(obj, matchedDeployments)