Skip to content

Sort component names in availability condition message to reduce spurious status writes#9020

Open
redhat-chai-bot wants to merge 1 commit into
openshift:mainfrom
redhat-chai-bot:fix-component-sort-status
Open

Sort component names in availability condition message to reduce spurious status writes#9020
redhat-chai-bot wants to merge 1 commit into
openshift:mainfrom
redhat-chai-bot:fix-component-sort-status

Conversation

@redhat-chai-bot

@redhat-chai-bot redhat-chai-bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Sort the notAvailable component name slice in controlPlaneComponentsAvailable() before joining it into the condition message string.

Problem

The controlPlaneComponentsAvailable() function in control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go builds a condition message listing unavailable components. It iterates ControlPlaneComponent resources returned by client.List(), which has no guaranteed ordering across calls. This produces non-deterministic messages like:

Waiting for components to be available: certified-operators-catalog, community-operators-catalog, redhat-operators-catalog
Waiting for components to be available: community-operators-catalog, redhat-operators-catalog, certified-operators-catalog

Each distinct message string causes the merge patch to include a condition change, bumping resourceVersion and triggering cascading watch events and reconciliation on the HostedCluster controller — even though nothing meaningful changed.

Fix

Add sort.Strings(notAvailable) before strings.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

    • Made control plane availability status messages consistent by listing unavailable components in a predictable alphabetical order.
  • Tests

    • Added coverage to verify the ordering of multiple unavailable components in status messages.

…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>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 7990a863-9027-4d90-b3d1-ffa5f0e6d1b9

📥 Commits

Reviewing files that changed from the base of the PR and between 0121785 and 5f76022.

📒 Files selected for processing (2)
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go
  • control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller_test.go

📝 Walkthrough

Walkthrough

The 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 etcd, kube-scheduler, and oauth-server are unavailable.

Suggested reviewers: bryan-cox, muraee

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: sorting unavailable component names to keep the availability message deterministic and reduce unnecessary status writes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PASS: The added test title is a static, descriptive string and contains no runtime-generated values or unstable identifiers.
Test Structure And Quality ✅ Passed PASS: The added case is a focused table-driven unit test; it uses an in-memory fake client, no cluster waits/timeouts, and matches existing test patterns.
Topology-Aware Scheduling Compatibility ✅ Passed Only sorts unavailable component names in a status message and adds a test; no pod specs, replicas, affinity, selectors, or topology-based scheduling logic changed.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR only adds a table-driven unit test, not new Ginkgo e2e tests, and the new case has no IPv4 or external-connectivity assumptions.
No-Weak-Crypto ✅ Passed The patch only sorts status-message names and adds a test; it introduces no weak crypto, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed Only a sort and test were added; no privileged flags, host* settings, SYS_ADMIN, or root escalation settings appear in the touched files.
No-Sensitive-Data-In-Logs ✅ Passed Only a sorted status message was added in controlPlaneComponentsAvailable; no new log statements or sensitive fields were introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from Nirshal and bryan-cox July 16, 2026 16:19
@openshift-ci openshift-ci Bot added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release and removed do-not-merge/needs-area labels Jul 16, 2026
@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: redhat-chai-bot
Once this PR has been reviewed and has the lgtm label, please assign cblecker for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.09%. Comparing base (3d0980b) to head (5f76022).
⚠️ Report is 4 commits behind head on main.

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     
Files with missing lines Coverage Δ
...ostedcontrolplane/hostedcontrolplane_controller.go 46.08% <100.00%> (+0.02%) ⬆️

... and 8 files with indirect coverage changes

Flag Coverage Δ
cmd-support 38.24% <ø> (-0.02%) ⬇️
cpo-hostedcontrolplane 46.17% <100.00%> (+<0.01%) ⬆️
cpo-other 45.21% <ø> (ø)
hypershift-operator 54.09% <ø> (ø)
other 33.59% <ø> (+1.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@redhat-chai-bot: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant