Skip to content

Commit e419a97

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. Signed-off-by: Anik Bhattacharjee <[email protected]>
1 parent 3e1a16d commit e419a97

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -976,14 +976,15 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
976976
return updateErr
977977
}
978978
return err
979-
} else {
979+
}
980+
981+
defer func() {
980982
subs = o.setSubsCond(subs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
981983
_, updateErr := o.updateSubscriptionStatuses(subs)
982984
if updateErr != nil {
983-
logger.WithError(updateErr).Debug("failed to update subs conditions")
985+
logger.WithError(updateErr).Warn("failed to update subscription conditions")
984986
}
985-
updatedSubs = o.setSubsCond(updatedSubs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
986-
}
987+
}()
987988

988989
// create installplan if anything updated
989990
if len(updatedSubs) > 0 {
@@ -1015,9 +1016,12 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
10151016
return err
10161017
}
10171018
updatedSubs = o.setIPReference(updatedSubs, maxGeneration+1, installPlanReference)
1018-
if _, err := o.updateSubscriptionStatuses(updatedSubs); err != nil {
1019-
logger.WithError(err).Debug("error ensuring subscription installplan state")
1020-
return err
1019+
for _, updatedSub := range updatedSubs {
1020+
for i, sub := range subs {
1021+
if sub.Name == updatedSub.Name && sub.Namespace == updatedSub.Namespace {
1022+
subs[i] = updatedSub
1023+
}
1024+
}
10211025
}
10221026
} else {
10231027
logger.Debugf("no subscriptions were updated")

0 commit comments

Comments
 (0)