Skip to content

Commit 099bb22

Browse files
committed
fix: report all degraded controller conditions instead of first only
checkControllerConditions() was returning early on the first degraded condition it encountered, so when multiple controllers were degraded simultaneously only one would be reflected in the operator's Degraded status message. Collect all degraded conditions and report them together.
1 parent 86d458c commit 099bb22

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pkg/controllers/clusteroperator_controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22+
"sort"
23+
"strings"
2224

2325
configv1 "github.com/openshift/api/config/v1"
2426
operatorv1 "github.com/openshift/api/operator/v1"
@@ -302,11 +304,12 @@ func (r *CloudOperatorReconciler) checkControllerConditions(ctx context.Context)
302304

303305
cloudConfigControllerAvailable := false
304306
trustedCABundleControllerAvailable := false
307+
var degradedMessages []string
305308

306309
for _, cond := range co.Status.Conditions {
307310
if cond.Type == cloudConfigControllerDegradedCondition || cond.Type == trustedCABundleControllerDegradedCondition {
308311
if cond.Status == configv1.ConditionTrue {
309-
return false, fmt.Errorf("failed to apply resources because %s condition is set to True: %s", cond.Type, cond.Message)
312+
degradedMessages = append(degradedMessages, fmt.Sprintf("%s condition is set to True: %s", cond.Type, cond.Message))
310313
}
311314
}
312315

@@ -319,6 +322,11 @@ func (r *CloudOperatorReconciler) checkControllerConditions(ctx context.Context)
319322
}
320323
}
321324

325+
if len(degradedMessages) > 0 {
326+
sort.Strings(degradedMessages)
327+
return false, fmt.Errorf("failed to apply resources because %s", strings.Join(degradedMessages, "; "))
328+
}
329+
322330
return cloudConfigControllerAvailable && trustedCABundleControllerAvailable, nil
323331
}
324332

0 commit comments

Comments
 (0)