From 7b0a05b3e28d598e78ca7290245945ec42dfedce Mon Sep 17 00:00:00 2001 From: akihikokuroda Date: Thu, 30 Dec 2021 16:37:05 -0500 Subject: [PATCH] put mutex around installplan creation Signed-off-by: akihikokuroda --- pkg/controller/operators/catalog/operator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/controller/operators/catalog/operator.go b/pkg/controller/operators/catalog/operator.go index 64d30ba6464..b69cd1f38fc 100644 --- a/pkg/controller/operators/catalog/operator.go +++ b/pkg/controller/operators/catalog/operator.go @@ -116,6 +116,7 @@ type Operator struct { installPlanTimeout time.Duration bundleUnpackTimeout time.Duration clientFactory clients.Factory + muInstallPlan sync.Mutex } type CatalogSourceSyncFunc func(logger *logrus.Entry, in *v1alpha1.CatalogSource) (out *v1alpha1.CatalogSource, continueSync bool, syncError error) @@ -1167,6 +1168,9 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, gen return nil, err } + o.muInstallPlan.Lock() + defer o.muInstallPlan.Unlock() + for _, installPlan := range installPlans { if installPlan.Spec.Generation == gen { return reference.GetReference(installPlan)