Skip to content

CNTRLPLANE-2939: Coordinate CRD lifecycle with Cluster CAPI Operator#8442

Merged
openshift-merge-bot[bot] merged 3 commits intoopenshift:release-4.22from
muraee:backport-capi-coordination
May 7, 2026
Merged

CNTRLPLANE-2939: Coordinate CRD lifecycle with Cluster CAPI Operator#8442
openshift-merge-bot[bot] merged 3 commits intoopenshift:release-4.22from
muraee:backport-capi-coordination

Conversation

@muraee
Copy link
Copy Markdown
Contributor

@muraee muraee commented May 6, 2026

Summary

  • Backport of CNTRLPLANE-2939: Coordinate CRD lifecycle with Cluster CAPI Operator #7996 to release-4.22
  • Coordinates CRD lifecycle with the Cluster CAPI Operator during hypershift install by setting unmanaged CRDs in the ClusterAPI singleton config and waiting for the operator to reconcile
  • Uses unstructured access for status.observedRevisionGeneration because the field is not present in the vendored operatorv1alpha1.ClusterAPIStatus type on release-4.22

Changes from main

The waitForCAPIOperatorSync function reads the ClusterAPI object as unstructured.Unstructured instead of the typed struct, extracting observedRevisionGeneration, currentRevision, and desiredRevision via unstructured.NestedInt64/NestedString. Tests use interceptor.Funcs to return unstructured objects directly, bypassing the fake client's typed round-trip.

Test plan

  • Unit tests pass (go test ./cmd/install/ -v)
  • Build succeeds (go build ./cmd/install/)
  • E2E: hypershift install on a cluster with Cluster CAPI Operator deployed

muraee and others added 2 commits May 6, 2026 16:45
When the ClusterAPI CRD (clusterapis.operator.openshift.io) is
registered on the management cluster, the install command now:

1. Detects CCAPIO presence by checking for the ClusterAPI CRD
2. Gets-or-creates the ClusterAPI config singleton and populates
   unmanagedCustomResourceDefinitions with HyperShift's CAPI CRD
   names (those with groups ending in .cluster.x-k8s.io)
3. Validates all CRDs via server-side dry-run before applying,
   regardless of CCAPIO presence, to catch webhook rejections
   and schema conflicts early

This prevents conflicts between HyperShift and CCAPIO when both
attempt to manage the same CAPI CRDs on the management cluster.

Ref: CNTRLPLANE-2939

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use JSON map for SSA patch payload instead of YamlSerializer to avoid
  zero-value serialization issues (ApplyConfiguration types for
  operator/v1alpha1 are not yet available in openshift/client-go)
- Return metadata.generation from ensureUnmanagedCRDs and pass it to
  waitForCAPIOperatorSync to prevent false positives from stale reads
- Add test case for stale object scenario

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 6, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 6, 2026

@muraee: This pull request references CNTRLPLANE-2939 which is a valid jira issue.

Details

In response to this:

Summary

  • Backport of CNTRLPLANE-2939: Coordinate CRD lifecycle with Cluster CAPI Operator #7996 to release-4.22
  • Coordinates CRD lifecycle with the Cluster CAPI Operator during hypershift install by setting unmanaged CRDs in the ClusterAPI singleton config and waiting for the operator to reconcile
  • Uses unstructured access for status.observedRevisionGeneration because the field is not present in the vendored operatorv1alpha1.ClusterAPIStatus type on release-4.22

Changes from main

The waitForCAPIOperatorSync function reads the ClusterAPI object as unstructured.Unstructured instead of the typed struct, extracting observedRevisionGeneration, currentRevision, and desiredRevision via unstructured.NestedInt64/NestedString. Tests use interceptor.Funcs to return unstructured objects directly, bypassing the fake client's typed round-trip.

Test plan

  • Unit tests pass (go test ./cmd/install/ -v)
  • Build succeeds (go build ./cmd/install/)
  • E2E: hypershift install on a cluster with Cluster CAPI Operator deployed

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 44b1c6cb-969c-4afa-98ff-ebbef37e39b3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested review from cblecker and csrwng May 6, 2026 15:01
@openshift-ci openshift-ci Bot added the area/cli Indicates the PR includes changes for CLI label May 6, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: muraee

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

The pull request process is described 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

@openshift-ci openshift-ci Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area labels May 6, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 52.50000% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.78%. Comparing base (41f254c) to head (c2b52a7).
⚠️ Report is 8 commits behind head on release-4.22.

Files with missing lines Patch % Lines
cmd/install/install.go 52.50% 54 Missing and 3 partials ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           release-4.22    #8442      +/-   ##
================================================
+ Coverage         34.76%   34.78%   +0.02%     
================================================
  Files               767      767              
  Lines             93314    93434     +120     
================================================
+ Hits              32442    32505      +63     
- Misses            58196    58250      +54     
- Partials           2676     2679       +3     
Files with missing lines Coverage Δ
cmd/install/install.go 51.51% <52.50%> (+0.11%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The vendored operatorv1alpha1.ClusterAPIStatus type on release-4.22
does not include the ObservedRevisionGeneration field. Switch
waitForCAPIOperatorSync to read the ClusterAPI object as unstructured
and extract status.observedRevisionGeneration, status.currentRevision,
and status.desiredRevision from the raw map. This allows the backport
to work without bumping the openshift/api dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@muraee muraee force-pushed the backport-capi-coordination branch from 1077b11 to c2b52a7 Compare May 6, 2026 15:14
@csrwng
Copy link
Copy Markdown
Contributor

csrwng commented May 6, 2026

/lgtm

@csrwng csrwng added the backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. label May 6, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 6, 2026
@muraee
Copy link
Copy Markdown
Contributor Author

muraee commented May 6, 2026

/verified bypass

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label May 6, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@muraee: The verified label has been added.

Details

In response to this:

/verified bypass

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.

@cblecker
Copy link
Copy Markdown
Member

cblecker commented May 6, 2026

/uncc

@openshift-ci openshift-ci Bot removed the request for review from cblecker May 6, 2026 17:28
@celebdor celebdor added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label May 7, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 7, 2026

@muraee: 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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 7c6d1fb into openshift:release-4.22 May 7, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cli Indicates the PR includes changes for CLI backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants