From 83968d92e91565632cd302448457bce72bdedaf6 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 Signed-off-by: nbn01 --- 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 72fabbc3..1fead796 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)