Skip to content

Commit 36d140b

Browse files
committed
Reduce number of times subscription statues are updated.
The statuses of the subscriptions are updated multiple number of times while syncing the resolving namespace. This commit switches to preserving the state of the subscription statues instead, and only updating the statuses on cluster only when it's neccessary.
1 parent 79eae9c commit 36d140b

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Diff for: pkg/controller/operators/catalog/operator.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -991,14 +991,16 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
991991
return updateErr
992992
}
993993
return err
994-
} else {
995-
subs = o.setSubsCond(subs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
994+
}
995+
996+
subs = o.setSubsCond(subs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
997+
defer func() {
996998
_, updateErr := o.updateSubscriptionStatuses(subs)
997999
if updateErr != nil {
998-
logger.WithError(updateErr).Debug("failed to update subs conditions")
1000+
logger.WithError(updateErr).Warn("failed to update subscription conditions")
9991001
}
1000-
updatedSubs = o.setSubsCond(updatedSubs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
1001-
}
1002+
}()
1003+
updatedSubs = o.setSubsCond(updatedSubs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
10021004

10031005
// create installplan if anything updated
10041006
if len(updatedSubs) > 0 {
@@ -1030,9 +1032,12 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
10301032
return err
10311033
}
10321034
updatedSubs = o.setIPReference(updatedSubs, maxGeneration+1, installPlanReference)
1033-
if _, err := o.updateSubscriptionStatuses(updatedSubs); err != nil {
1034-
logger.WithError(err).Debug("error ensuring subscription installplan state")
1035-
return err
1035+
for _, updatedSub := range updatedSubs {
1036+
for i, sub := range subs {
1037+
if sub.Name == updatedSub.Name && sub.Namespace == updatedSub.Namespace {
1038+
subs[i] = updatedSub
1039+
}
1040+
}
10361041
}
10371042
} else {
10381043
logger.Debugf("no subscriptions were updated")

0 commit comments

Comments
 (0)