File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,25 @@ const (
178
178
asExpectedReason = "AsExpected"
179
179
)
180
180
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
+
181
200
// syncDegradedStatus applies the new condition to the mco's ClusterOperator object.
182
201
func (optr * Operator ) syncDegradedStatus (co * configv1.ClusterOperator , ierr syncError ) {
183
202
Original file line number Diff line number Diff line change @@ -192,6 +192,11 @@ func (optr *Operator) syncAll(syncFuncs []syncFunc) error {
192
192
}
193
193
break
194
194
}
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
+ }
195
200
}
196
201
197
202
optr .syncDegradedStatus (updatedCO , syncErr )
You can’t perform that action at this time.
0 commit comments