Skip to content

CNTRLPLANE-3532: migrate HCCO/route status patches to statuspatching - #9385

Open
vsolanki12 wants to merge 2 commits into
openshift:mainfrom
vsolanki12:vsolanki/cntrlplane-3532-hcco-route-migration
Open

CNTRLPLANE-3532: migrate HCCO/route status patches to statuspatching#9385
vsolanki12 wants to merge 2 commits into
openshift:mainfrom
vsolanki12:vsolanki/cntrlplane-3532-hcco-route-migration

Conversation

@vsolanki12

@vsolanki12 vsolanki12 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Completes 2 of the remaining CNTRLPLANE-3532 status-patching sites flagged during #8966's review:

  • HCCO resources.go: destroyCloudResources's CloudResourcesDestroyed condition patch — was raw MergeFromWithOptimisticLock (correct locking, no retry). Migrated to statuspatching.PatchStatusCondition.
  • CPO hostedcontrolplane_controller.go: removeHCPIngressFromRoutes's route-ingress status patch — was bare client.MergeFrom with no optimistic lock at all, the worst of the remaining sites. Migrated to statuspatching.PatchStatus, with the ingress-filtering logic moved inside the mutate closure so it recomputes against whatever is freshly fetched on retry instead of replaying a value captured beforehand.

Part of the broader CNTRLPLANE-3532 migration. Independent of #8966 — different functions/files, no overlap, no ordering dependency.

Which issue(s) this PR fixes:

Part of CNTRLPLANE-3532 — does not close it, see remaining work below.

Special notes for your reviewer:

  • Design note on the HCCO site (deliberate choice, not an oversight): resourcesDestroyedCond is computed synchronously from a live guest-cluster check (ensureCloudResourcesDestroyed) right before the patch — traced the full call chain, it depends only on Spec + live checks, never on hcp.Status. So replaying it on PatchStatusCondition's retry is safe even if CPO's fallback timeout condition landed on the object in between — HCCO is the authoritative writer for this condition when reachable, and this is intentionally a "last-live-write-wins" pattern, not a race.
  • Still not done for CNTRLPLANE-3532 (separate follow-up): static analysis linter + make lint integration; AGENTS.md guidance update; support/statuspatching JSON Patch (RFC 6902) variant + nullable-field test; resources.go:1125 (reconcileConfig's Infrastructure status update) — same "no retry-on-conflict" bug class, different resource/function, found during review of this PR but out of scope here.
  • No new tests added — existing tests (TestDestroyCloudResources*, TestRemoveHCPIngressFromRoutes) already exercise both call sites end-to-end against a real fake client and pass unchanged; the shared helper's retry-on-conflict mechanics are covered separately in support/statuspatching/statuspatching_test.go.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when updating route ingress status during concurrent changes.
    • Prevented cleanup updates from overwriting newer routing information.
    • Made cloud resource cleanup status updates safer and more consistent during retries.

…uspatching

Replace the raw MergeFromWithOptimisticLock status patch in
destroyCloudResources with statuspatching.PatchStatusCondition, adding
retry-on-conflict. The condition is derived from a live guest-cluster
check on each call, so replaying it on retry is safe even if CPO's
timeout fallback landed on the object in between.

Part of the broader CNTRLPLANE-3532 status-patching migration.

Signed-off-by: Vimal Solanki <vsolanki@redhat.com>
…tching

removeHCPIngressFromRoutes used a bare client.MergeFrom with no
optimistic lock at all. Switch to statuspatching.PatchStatus and move
the ingress filtering inside the mutate closure so it recomputes
against whatever is freshly fetched on each retry, rather than
replaying a value captured before the patch.

Part of the broader CNTRLPLANE-3532 status-patching migration.

Signed-off-by: Vimal Solanki <vsolanki@redhat.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

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 24, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 24, 2026

Copy link
Copy Markdown

@vsolanki12: This pull request references CNTRLPLANE-3532 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set.

Details

In response to this:

What this PR does / why we need it:

Completes 2 of the remaining CNTRLPLANE-3532 status-patching sites flagged during #8966's review:

  • HCCO resources.go: destroyCloudResources's CloudResourcesDestroyed condition patch — was raw MergeFromWithOptimisticLock (correct locking, no retry). Migrated to statuspatching.PatchStatusCondition.
  • CPO hostedcontrolplane_controller.go: removeHCPIngressFromRoutes's route-ingress status patch — was bare client.MergeFrom with no optimistic lock at all, the worst of the remaining sites. Migrated to statuspatching.PatchStatus, with the ingress-filtering logic moved inside the mutate closure so it recomputes against whatever is freshly fetched on retry instead of replaying a value captured beforehand.

Part of the broader CNTRLPLANE-3532 migration. Independent of #8966 — different functions/files, no overlap, no ordering dependency.

Design note on the HCCO site (called out proactively since it's a deliberate choice, not an oversight): resourcesDestroyedCond is computed synchronously from a live guest-cluster check (ensureCloudResourcesDestroyed) right before the patch — traced the full call chain, it depends only on Spec + live checks, never on hcp.Status. So replaying it on PatchStatusCondition's retry is safe even if CPO's fallback timeout condition landed on the object in between — HCCO is the authoritative writer for this condition when reachable, and this is intentionally a "last-live-write-wins" pattern, not a race.

Still not done for CNTRLPLANE-3532 (separate follow-up):

  • Static analysis linter + make lint integration
  • AGENTS.md guidance update
  • support/statuspatching JSON Patch (RFC 6902) variant + nullable-field test
  • resources.go:1125 (reconcileConfig's Infrastructure status update) — same "no retry-on-conflict" bug class, different resource/function, found during review of this PR but out of scope here

Which issue(s) this PR fixes:

Part of CNTRLPLANE-3532 — does not close it, see remaining work above.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests. (existing tests cover both call sites end-to-end; no new tests needed — see commit messages)

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.

@openshift-ci openshift-ci Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-area labels Aug 24, 2026
@coderabbitai

coderabbitai Bot commented Aug 24, 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: Pro Plus

Run ID: fc2ae85b-2333-4761-a8c6-d0809ec1d18a

📥 Commits

Reviewing files that changed from the base of the PR and between a2edb28 and 673601c.

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

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Route ingress cleanup now uses statuspatching.PatchStatus and recomputes filtered ingress entries from current route state during retries. Cloud resource cleanup now uses statuspatching.PatchStatusCondition to update CloudResourcesDestroyed from the live cleanup result.

Suggested reviewers: bryan-cox, csrwng

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
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 The PR diff changes only two production Go files. It adds no test files or Ginkgo title expressions, so it introduces no dynamic or overly specific test names.
Test Structure And Quality ✅ Passed The PR changes only two production Go files; no *_test.go files or Ginkgo blocks changed, so this test-structure check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The PR diff changes only status patching and ingress-condition logic; it adds no manifests, replicas, affinities, topology spreads, selectors, tolerations, or PDB constraints.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR changes only two production Go files; the complete diff adds no Ginkgo tests, IPv4 assumptions, or external connectivity requirements.
No-Weak-Crypto ✅ Passed The PR only changes status patching and ingress filtering; the added diff introduces no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons. Existing crypto/rand is unchanged.
Container-Privileges ✅ Passed The PR changes only two Go controller files. Added lines contain no privilege markers, security contexts, or manifest files, so no checked container privilege is introduced.
No-Sensitive-Data-In-Logs ✅ Passed The PR adds no logging calls or sensitive values. Added code only performs status patching and returns generic errors; statuspatching has no logging side effects.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating HCCO and route status updates to the statuspatching utilities.
✨ 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 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release label Aug 24, 2026
@openshift-ci

openshift-ci Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vsolanki12
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 Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.12%. Comparing base (a2edb28) to head (673601c).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...ostedcontrolplane/hostedcontrolplane_controller.go 77.77% 2 Missing ⚠️
...rconfigoperator/controllers/resources/resources.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9385      +/-   ##
==========================================
- Coverage   46.13%   46.12%   -0.01%     
==========================================
  Files         783      783              
  Lines       98377    98375       -2     
==========================================
- Hits        45382    45380       -2     
- Misses      49919    49920       +1     
+ Partials     3076     3075       -1     
Files with missing lines Coverage Δ
...ostedcontrolplane/hostedcontrolplane_controller.go 47.60% <77.77%> (-0.03%) ⬇️
...rconfigoperator/controllers/resources/resources.go 57.84% <60.00%> (-0.02%) ⬇️
Flag Coverage Δ
cmd-support 39.61% <ø> (ø)
cpo-hostedcontrolplane 48.31% <77.77%> (-0.01%) ⬇️
cpo-other 46.11% <60.00%> (-0.01%) ⬇️
hypershift-operator 57.14% <ø> (ø)
other 34.71% <ø> (ø)

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.

@vsolanki12
vsolanki12 marked this pull request as ready for review August 25, 2026 06:12
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 25, 2026
@openshift-ci
openshift-ci Bot requested review from csrwng and enxebre August 25, 2026 06:12
@openshift-ci

openshift-ci Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@vsolanki12: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 673601c link true /test security

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 jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants