NO-JIRA: fix: report all degraded controller conditions instead of first only#444#444
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughModified Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/controllers/clusteroperator_controller.go (1)
324-326: Consider sorting degraded messages before join to make error text fully deterministic.The current output order depends on
co.Status.Conditionsiteration order. Sorting beforestrings.Joinmakes exact message text stable across reconciles/tests.Suggested diff
import ( "context" "fmt" + "sort" "strings" @@ if len(degradedMessages) > 0 { + sort.Strings(degradedMessages) return false, fmt.Errorf("failed to apply resources because %s", strings.Join(degradedMessages, "; ")) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/controllers/clusteroperator_controller.go` around lines 324 - 326, The error string built from degradedMessages is non-deterministic because it reflects iteration order; before calling strings.Join(degradedMessages, "; "), sort the slice (e.g., use sort.Strings(degradedMessages)) so the output is stable across runs, and add the necessary import for "sort"; update the block that returns fmt.Errorf("failed to apply resources because %s", strings.Join(degradedMessages, "; ")) to sort degradedMessages first.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/controllers/clusteroperator_controller.go`:
- Around line 324-326: The error string built from degradedMessages is
non-deterministic because it reflects iteration order; before calling
strings.Join(degradedMessages, "; "), sort the slice (e.g., use
sort.Strings(degradedMessages)) so the output is stable across runs, and add the
necessary import for "sort"; update the block that returns fmt.Errorf("failed to
apply resources because %s", strings.Join(degradedMessages, "; ")) to sort
degradedMessages first.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c22b36ca-2842-47a3-9960-a96b40ff44a2
📒 Files selected for processing (1)
pkg/controllers/clusteroperator_controller.go
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.
07c949d to
099bb22
Compare
|
I should probably integrate this in to #436 |
|
feel free to do so. |
|
@RadekManak: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/approve |
|
@nrb: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/retitle NO-JIRA: fix: report all degraded controller conditions instead of first only#444 |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nrb The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@RadekManak: This pull request explicitly references no jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Summary
checkControllerConditions()was iterating the CO status conditions and returning early on the first degraded condition found, so when bothCloudConfigControllerandTrustedCABundleControllerare degraded simultaneously, only one gets reflected in the operator'sDegradedstatus message — whichever happens to appear first in the slice.TrustedCABundleControllerControllerDegradedin the message but gotCloudConfigControllerDegradedinstead.Fix
Collect all degraded conditions in a single pass and return a combined error message, so all failing controllers are always reported.
Test plan
[sig-cluster-lifecycle] Cluster_Infrastructure CCM Medium-70566-Garbage in cloud-controller-manager status— theDegradedmessage will now contain both conditions when both controllers fail, making the test deterministic