Skip to content
Closed
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
14 changes: 8 additions & 6 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1654,12 +1654,6 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, gen
return nil, nil
}

// Check if any existing installplans are creating the same resources
installPlans, err := o.listInstallPlans(namespace)
if err != nil {
return nil, err
}

// There are multiple(2) worker threads process the namespaceQueue.
// Both worker can work at the same time when 2 separate updates are made for the namespace.
// The following sequence causes 2 installplans are created for a subscription
Expand All @@ -1680,6 +1674,14 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, gen
o.muInstallPlan.Lock()
defer o.muInstallPlan.Unlock()

// Check if any existing installplans are creating the same resources
// This must be done AFTER acquiring the lock to ensure worker 2 sees
// the installplan created by worker 1
installPlans, err := o.listInstallPlans(namespace)
if err != nil {
return nil, err
}

for _, installPlan := range installPlans {
if installPlan.Spec.Generation == gen {
return reference.GetReference(installPlan)
Expand Down