Skip to content

Commit 11006a4

Browse files
Merge pull request #4826 from openshift-cherrypick-robot/cherry-pick-4818-to-release-4.17
[release-4.17] OCPBUGS-49716: MCO CO degrades are stuck on until master pool updates complete
2 parents 830665b + eca9074 commit 11006a4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pkg/operator/status.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,25 @@ const (
178178
asExpectedReason = "AsExpected"
179179
)
180180

181+
// This function clears a prior CO degrade condition set by a sync function. If the CO is not
182+
// not degraded, or was degraded by another sync function, this will be a no-op.
183+
func (optr *Operator) clearDegradedStatus(co *configv1.ClusterOperator, syncFn string) (*configv1.ClusterOperator, error) {
184+
if cov1helpers.IsStatusConditionFalse(co.Status.Conditions, configv1.OperatorDegraded) {
185+
return co, nil
186+
}
187+
degradedStatusCondition := cov1helpers.FindStatusCondition(co.Status.Conditions, configv1.OperatorDegraded)
188+
if degradedStatusCondition == nil {
189+
return co, nil
190+
}
191+
if degradedStatusCondition.Reason != taskFailed(syncFn) {
192+
return co, nil
193+
}
194+
newCO := co.DeepCopy()
195+
// Clear the degraded by applying an empty sync error object
196+
optr.syncDegradedStatus(newCO, syncError{})
197+
return optr.updateClusterOperatorStatus(co, &newCO.Status, nil)
198+
}
199+
181200
// syncDegradedStatus applies the new condition to the mco's ClusterOperator object.
182201
func (optr *Operator) syncDegradedStatus(co *configv1.ClusterOperator, ierr syncError) {
183202

pkg/operator/sync.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ func (optr *Operator) syncAll(syncFuncs []syncFunc) error {
192192
}
193193
break
194194
}
195+
// If there was no sync error for this function, attempt to clear degrade
196+
updatedCO, err = optr.clearDegradedStatus(updatedCO, sf.name)
197+
if err != nil {
198+
return fmt.Errorf("error clearing degraded status: %v", err)
199+
}
195200
}
196201

197202
optr.syncDegradedStatus(updatedCO, syncErr)

0 commit comments

Comments
 (0)