Skip to content

Commit 5de47d1

Browse files
committed
fix(install): account for installplans when calculating generation
Account for existing InstallPlans while calculating the maximum generation. This ensures new Subscriptions get a new generation and are never associated with an existing InstallPlan in cases where previous Subscriptions were deleted.
1 parent 3a5c154 commit 5de47d1

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
@@ -854,6 +854,17 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
854854
// create installplan if anything updated
855855
if len(updatedSubs) > 0 {
856856
logger.Debug("resolution caused subscription changes, creating installplan")
857+
// Finish calculating max generation by checking the existing installplans
858+
installPlans, err := o.listInstallPlans(namespace)
859+
if err != nil {
860+
return err
861+
}
862+
for _, ip := range installPlans {
863+
if gen := ip.Spec.Generation; gen > maxGeneration {
864+
maxGeneration = gen
865+
}
866+
}
867+
857868
// any subscription in the namespace with manual approval will force generated installplans to be manual
858869
// TODO: this is an odd artifact of the older resolver, and will probably confuse users. approval mode could be on the operatorgroup?
859870
installPlanApproval := v1alpha1.ApprovalAutomatic
@@ -1205,7 +1216,7 @@ func (o *Operator) gcInstallPlans(log logrus.FieldLogger, namespace string) {
12051216

12061217
// we only consider maxDeletesPerSweep more than the allowed number of installplans for delete at one time
12071218
ips := allIps
1208-
if len(ips) > maxInstallPlanCount + maxDeletesPerSweep {
1219+
if len(ips) > maxInstallPlanCount+maxDeletesPerSweep {
12091220
ips = allIps[:maxInstallPlanCount+maxDeletesPerSweep]
12101221
}
12111222

0 commit comments

Comments
 (0)