Skip to content

Commit ac88ff0

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 <anikbhattacharya93@gmail.com>
1 parent 3e1a16d commit ac88ff0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -976,14 +976,16 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
976976
return updateErr
977977
}
978978
return err
979-
} else {
980-
subs = o.setSubsCond(subs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
979+
}
980+
981+
subs = o.setSubsCond(subs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
982+
defer func() {
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+
}()
988+
updatedSubs = o.setSubsCond(updatedSubs, v1alpha1.SubscriptionResolutionFailed, "", "", false)
987989

988990
// create installplan if anything updated
989991
if len(updatedSubs) > 0 {
@@ -1015,9 +1017,12 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
10151017
return err
10161018
}
10171019
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
1020+
for _, updatedSub := range updatedSubs {
1021+
for i, sub := range subs {
1022+
if sub.Name == updatedSub.Name && sub.Namespace == updatedSub.Namespace {
1023+
subs[i] = updatedSub
1024+
}
1025+
}
10211026
}
10221027
} else {
10231028
logger.Debugf("no subscriptions were updated")

0 commit comments

Comments
 (0)