Skip to content

Commit

Permalink
Stop subscription intervention if CSV already set
Browse files Browse the repository at this point in the history
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 <jkulikau@redhat.com>
  • Loading branch information
JustinKuli authored and openshift-merge-bot[bot] committed Jun 10, 2024
1 parent 04184bc commit 40d47e0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions controllers/operatorpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)
Expand Down

0 comments on commit 40d47e0

Please sign in to comment.