Skip to content

Commit 8724fe0

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 d1ebc80 commit 8724fe0

File tree

4 files changed

+410
-156
lines changed

4 files changed

+410
-156
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,17 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
845845
// create installplan if anything updated
846846
if len(updatedSubs) > 0 {
847847
logger.Debug("resolution caused subscription changes, creating installplan")
848+
// Finish calculating max generation by checking the existing installplans
849+
installPlans, err := o.listInstallPlans(namespace)
850+
if err != nil {
851+
return err
852+
}
853+
for _, ip := range installPlans {
854+
if gen := ip.Spec.Generation; gen > maxGeneration {
855+
maxGeneration = gen
856+
}
857+
}
858+
848859
// any subscription in the namespace with manual approval will force generated installplans to be manual
849860
// TODO: this is an odd artifact of the older resolver, and will probably confuse users. approval mode could be on the operatorgroup?
850861
installPlanApproval := v1alpha1.ApprovalAutomatic
@@ -1194,7 +1205,7 @@ func (o *Operator) gcInstallPlans(log logrus.FieldLogger, namespace string) {
11941205

11951206
// we only consider maxDeletesPerSweep more than the allowed number of installplans for delete at one time
11961207
ips := allIps
1197-
if len(ips) > maxInstallPlanCount + maxDeletesPerSweep {
1208+
if len(ips) > maxInstallPlanCount+maxDeletesPerSweep {
11981209
ips = allIps[:maxInstallPlanCount+maxDeletesPerSweep]
11991210
}
12001211

0 commit comments

Comments
 (0)