diff --git a/pkg/controller/operators/olm/operator.go b/pkg/controller/operators/olm/operator.go index 954b712b040..1d8021fa44a 100644 --- a/pkg/controller/operators/olm/operator.go +++ b/pkg/controller/operators/olm/operator.go @@ -1423,9 +1423,9 @@ func (a *Operator) ensureDeploymentAnnotations(logger *logrus.Entry, csv *v1alph return nil } - var depNames []string + depNames := make(map[string]struct{}) for _, dep := range strategyDetailsDeployment.DeploymentSpecs { - depNames = append(depNames, dep.Name) + depNames[dep.Name] = struct{}{} } existingDeployments, err := a.lister.AppsV1().DeploymentLister().Deployments(csv.GetNamespace()).List(labels.Everything()) if err != nil { @@ -1435,7 +1435,9 @@ func (a *Operator) ensureDeploymentAnnotations(logger *logrus.Entry, csv *v1alph // compare deployments to see if any need to be created/updated existingMap := map[string]*appsv1.Deployment{} for _, d := range existingDeployments { - existingMap[d.GetName()] = d + if _, ok := depNames[d.GetName()]; ok { + existingMap[d.GetName()] = d + } } updateErrs := []error{} for _, dep := range existingMap {