From 681998eaea7b178112f3df6452dc7ef1d867e155 Mon Sep 17 00:00:00 2001 From: Justin Kulikauskas Date: Mon, 10 Jun 2024 10:46:51 -0400 Subject: [PATCH] Stop subscription intervention if CSV already set Especially in the case of an active upgrade, the previous intervention logic could fight with OLM while setting the CurrentCSV in the sub status. Now, if CurrentCSV or InstalledCSV are set, no intervention will be done. Signed-off-by: Justin Kulikauskas (cherry picked from commit 40d47e06b718be422a5297899ae2183e4e57ef84) --- controllers/operatorpolicy_controller.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/controllers/operatorpolicy_controller.go b/controllers/operatorpolicy_controller.go index ff75c13a..3bb94c80 100644 --- a/controllers/operatorpolicy_controller.go +++ b/controllers/operatorpolicy_controller.go @@ -1319,6 +1319,12 @@ func (r *OperatorPolicyReconciler) considerResolutionFailed( // Do the "intervention" + if mergedSub.Status.InstalledCSV != "" || mergedSub.Status.CurrentCSV != "" { + opLog.Info("The subscription already points to a CSV, not intervening", "currentSub", mergedSub) + + return mergedSub, nil, changed, nil + } + watcher := opPolIdentifier(policy.Namespace, policy.Name) existingCSV, err := r.DynamicWatcher.Get(watcher, clusterServiceVersionGVK, mergedSub.Namespace, unrefCSVMatches[1]) @@ -1344,14 +1350,15 @@ func (r *OperatorPolicyReconciler) considerResolutionFailed( return mergedSub, nil, changed, nil } + opLog.Info("Updating Subscription status to point to CSV", + "csvName", existingCSV.GetName(), "currentSub", mergedSub) + if mergedSub.Status.LastUpdated.IsZero() { mergedSub.Status.LastUpdated = metav1.Now() } mergedSub.Status.CurrentCSV = existingCSV.GetName() - opLog.Info("Updating Subscription status to point to CSV", "csvName", existingCSV.GetName()) - if err := r.TargetClient.Status().Update(ctx, mergedSub); err != nil { return mergedSub, nil, changed, fmt.Errorf("error updating the Subscription status to point to the CSV: %w", err)