Skip to content

Commit 63b96f4

Browse files
Merge pull request #1686 from openshift-cherrypick-robot/cherry-pick-1684-to-release-4.5
[release-4.5] Bug 1864121: fix(install): account for installplans when calculating generation
2 parents 367eeca + 93017bc commit 63b96f4

File tree

2 files changed

+353
-156
lines changed

2 files changed

+353
-156
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,17 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
852852
// create installplan if anything updated
853853
if len(updatedSubs) > 0 {
854854
logger.Debug("resolution caused subscription changes, creating installplan")
855+
// Finish calculating max generation by checking the existing installplans
856+
installPlans, err := o.listInstallPlans(namespace)
857+
if err != nil {
858+
return err
859+
}
860+
for _, ip := range installPlans {
861+
if gen := ip.Spec.Generation; gen > maxGeneration {
862+
maxGeneration = gen
863+
}
864+
}
865+
855866
// any subscription in the namespace with manual approval will force generated installplans to be manual
856867
// TODO: this is an odd artifact of the older resolver, and will probably confuse users. approval mode could be on the operatorgroup?
857868
installPlanApproval := v1alpha1.ApprovalAutomatic
@@ -1201,7 +1212,7 @@ func (o *Operator) gcInstallPlans(log logrus.FieldLogger, namespace string) {
12011212

12021213
// we only consider maxDeletesPerSweep more than the allowed number of installplans for delete at one time
12031214
ips := allIps
1204-
if len(ips) > maxInstallPlanCount + maxDeletesPerSweep {
1215+
if len(ips) > maxInstallPlanCount+maxDeletesPerSweep {
12051216
ips = allIps[:maxInstallPlanCount+maxDeletesPerSweep]
12061217
}
12071218

0 commit comments

Comments
 (0)