Sort component names in availability condition message to reduce spurious status writes#9020
Conversation
…s writes controlPlaneComponentsAvailable() iterates over ControlPlaneComponent resources returned by client.List(), which has no guaranteed ordering. The resulting status condition message listing unavailable components is therefore non-deterministic, causing spurious status writes on each reconciliation even when nothing has changed. Sort the notAvailable slice before joining it into the message so the output is deterministic and identical across reconcile loops. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe controller now sorts unavailable control plane component names before constructing the “Waiting for components to be available” status message. A table-driven test verifies deterministic ordering when Suggested reviewers: 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: redhat-chai-bot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9020 +/- ##
==========================================
- Coverage 44.15% 44.09% -0.07%
==========================================
Files 772 779 +7
Lines 96260 97976 +1716
==========================================
+ Hits 42503 43198 +695
- Misses 50816 51746 +930
- Partials 2941 3032 +91
... and 8 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@redhat-chai-bot: 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. |
Summary
Sort the
notAvailablecomponent name slice incontrolPlaneComponentsAvailable()before joining it into the condition message string.Problem
The
controlPlaneComponentsAvailable()function incontrol-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.gobuilds a condition message listing unavailable components. It iteratesControlPlaneComponentresources returned byclient.List(), which has no guaranteed ordering across calls. This produces non-deterministic messages like:Each distinct message string causes the merge patch to include a condition change, bumping
resourceVersionand triggering cascading watch events and reconciliation on the HostedCluster controller — even though nothing meaningful changed.Fix
Add
sort.Strings(notAvailable)beforestrings.Join(notAvailable, ", "). This makes the message deterministic, so repeated reconciliations with the same set of unavailable components produce identical condition messages, eliminating spurious status writes.Impact
This is a targeted fix for one contributor to the excessive wasted status writes observed across the Hyperfleet. The change is minimal and safe — it only affects the ordering of names in a human-readable message.
@psav requested in Slack thread
Summary by CodeRabbit
Bug Fixes
Tests