Skip to content

Commit 576fcf2

Browse files
author
Per Goncalves da Silva
committed
Patch boxcutter steps to rewrite Progressing cond. to follow original contract
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent e7fe157 commit 576fcf2

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

internal/operator-controller/controllers/boxcutter_reconcile_steps.go

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ func ApplyBundleWithBoxcutter(a Applier) ReconcileStepFunc {
124124
return ctx, nil, err
125125
}
126126

127+
// Repopulate active revisions to avoid duplicates
128+
ext.Status.ActiveRevisions = nil
129+
127130
// Mirror Available/Progressing conditions from the installed revision
128131
if i := revisionStates.Installed; i != nil {
129132
for _, cndType := range []string{ocv1.ClusterExtensionRevisionTypeAvailable, ocv1.ClusterExtensionRevisionTypeProgressing} {
130-
cnd := *apimeta.FindStatusCondition(i.Conditions, cndType)
131-
apimeta.SetStatusCondition(&ext.Status.Conditions, cnd)
133+
if cnd := apimeta.FindStatusCondition(i.Conditions, cndType); cnd != nil {
134+
apimeta.SetStatusCondition(&ext.Status.Conditions, *cnd)
135+
}
132136
}
133137
ext.Status.Install = &ocv1.ClusterExtensionInstallStatus{
134138
Bundle: i.BundleMetadata,
@@ -143,16 +147,33 @@ func ApplyBundleWithBoxcutter(a Applier) ReconcileStepFunc {
143147
if pcnd != nil {
144148
apimeta.SetStatusCondition(&ext.Status.Conditions, *pcnd)
145149
}
146-
if acnd := apimeta.FindStatusCondition(r.Conditions, ocv1.ClusterExtensionRevisionTypeAvailable); pcnd.Status == metav1.ConditionFalse && acnd != nil && acnd.Status != metav1.ConditionTrue {
147-
apimeta.SetStatusCondition(&rs.Conditions, *acnd)
150+
acnd := apimeta.FindStatusCondition(r.Conditions, ocv1.ClusterExtensionRevisionTypeAvailable)
151+
if acnd != nil && pcnd != nil && pcnd.Status == metav1.ConditionFalse && acnd.Status != metav1.ConditionTrue {
152+
apimeta.SetStatusCondition(&ext.Status.Conditions, *acnd)
148153
}
149154
}
150-
if len(ext.Status.ActiveRevisions) == 0 {
151-
ext.Status.ActiveRevisions = []ocv1.RevisionStatus{rs}
152-
} else {
153-
ext.Status.ActiveRevisions = append(ext.Status.ActiveRevisions, rs)
155+
ext.Status.ActiveRevisions = append(ext.Status.ActiveRevisions, rs)
156+
}
157+
158+
// Rewrite Progressing condition to respect the existing contract
159+
// Currently ClusterExtension treats the Progressing condition in the same way as the Deployment resource
160+
// It signals there's nothing in the way of the resource progressing rather than the resource is undergoing
161+
// active reconciliation at the moment. In order to not break the original contract, we rewrite the condition.
162+
// This should be temporary until we understand whether we can change how the Progressing condition operates.
163+
if cnd := apimeta.FindStatusCondition(ext.Status.Conditions, ocv1.ClusterExtensionRevisionTypeProgressing); cnd != nil {
164+
switch cnd.Reason {
165+
case ocv1.ClusterExtensionRevisionReasonRolledOut:
166+
cnd.Status = metav1.ConditionTrue
167+
cnd.Reason = ocv1.ReasonSucceeded
168+
case ocv1.ClusterExtensionRevisionReasonRolloutError:
169+
cnd.Status = metav1.ConditionTrue
170+
cnd.Reason = ocv1.ReasonRetrying
154171
}
172+
apimeta.SetStatusCondition(&ext.Status.Conditions, *cnd)
155173
}
174+
l.Info("pre extension conditions", "conds", ext.Status.Conditions)
175+
setInstalledStatusFromRevisionStates(ext, revisionStates)
176+
l.Info("post extension conditions", "conds", ext.Status.Conditions)
156177
return ctx, nil, nil
157178
}
158179
}

0 commit comments

Comments
 (0)