Skip to content

OCPCLOUD-3541: Use feature gates consistently - #603

Open
mdbooth wants to merge 4 commits into
openshift:mainfrom
openshift-cloud-team:OCPCLOUD-3541
Open

OCPCLOUD-3541: Use feature gates consistently#603
mdbooth wants to merge 4 commits into
openshift:mainfrom
openshift-cloud-team:OCPCLOUD-3541

Conversation

@mdbooth

@mdbooth mdbooth commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This change removes various hard-coded assumptions in the code about which
platforms are supported and uses feature gates exclusively for feature
enablement. Specifically:

  • When ClusterAPIMachineMigration is enabled we now always run the operator,
    regardless of whether the platform has support.
  • Consequently we always install core CAPI, even if platform support is not yet
    enabled.
  • The revision controller now checks the per-platform feature gate before
    enabling any platform-specific profiles.
  • The machine-api-migration entrypoint now uses the MachineAPIMigration
    featuregate and the per-platform MachineAPIMigration instead of hard-coding
    AWS and OpenStack.

Summary by CodeRabbit

  • New Features

    • Platform-specific components are now included only when their corresponding feature gates are enabled.
    • Machine API migration components now start only when migration is enabled for the detected platform.
  • Bug Fixes

    • Unsupported platforms no longer trigger unnecessary deployment removal or misleading availability status.
    • Controller startup now handles disabled features and unsupported platforms cleanly without waiting indefinitely.
  • Refactor

    • Platform detection and feature-gate handling have been streamlined for more consistent controller behavior.

@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 Jun 18, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Infrastructure type detection now returns two values, platform-specific providers and migration controllers honor feature gates, and controller startup wiring is simplified. Unsupported-platform reconciliation branches are removed, with corresponding tests and dependency updates.

Changes

Platform and feature-gated controller flow

Layer / File(s) Summary
Infrastructure type return contract
pkg/util/platform.go, cmd/capi-controllers/main.go, e2e/webhook_test.go, pkg/controllers/machinesync/*_test.go, pkg/controllers/machinesetsync/*_test.go
GetCAPITypesForInfrastructure now returns infrastructure types and an error; callers use the revised two-value signature.
Revision provider feature gates
pkg/controllers/revision/*
RevisionController receives feature gates and filters platform-scoped providers accordingly; unit and integration tests cover enabled and disabled gates.
Migration controller selection
cmd/machine-api-migration/main.go, pkg/util/featuregates.go
Migration startup selects controllers through feature-gate and platform checks and returns no controllers when migration is disabled or unsupported.
Controller wiring and platform-neutral reconciliation
cmd/capi-installer/main.go, cmd/capi-operator/main.go, pkg/controllers/clusteroperator/*, pkg/controllers/installerdeployment/*
Startup wiring passes feature gates to revision setup, while cluster operator and installer deployment reconciliation no longer use platform support fields.
Dependency and fuzzing updates
go.mod, pkg/conversion/test/fuzz/fuzz.go
The klog dependency uses k8s.io/klog/v2, and MachineSetStatus fuzzing clears the derived label selector earlier.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Main
  participant getControllers
  participant FeatureGates
  participant Infrastructure
  participant allControllers
  Main->>getControllers: Select migration reconcilers
  getControllers->>FeatureGates: GetFeatureGates
  getControllers->>Infrastructure: GetCAPITypesForInfrastructure
  getControllers->>allControllers: Build enabled reconcilers
  allControllers-->>Main: Return controller map
Loading

Suggested reviewers: nrb, theobarberbany

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Microshift Test Compatibility ⚠️ Warning The new e2e webhook tests unconditionally read config.openshift.io/v1 Infrastructure via infra/GetCAPITypesForInfrastructure and have no MicroShift skip/tag. Add a [Skipped:MicroShift] or IsMicroShiftCluster() guard, or tag the test with an appropriate apigroup: if it should be excluded.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: standardizing feature-gate usage and removing hard-coded platform assumptions.
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 Touched Ginkgo titles are static, descriptive strings; none include generated names, timestamps, UUIDs, or other run-specific values.
Test Structure And Quality ✅ Passed Updated specs keep one-behavior It blocks, use BeforeEach/DeferCleanup cleanup, and cluster waits have explicit timeouts.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The only e2e change is a return-value adjustment in an existing webhook test; no new Ginkgo specs or multi-node assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed No new anti-affinity, topology-spread, nodeSelector, replica-count, or PDB logic was added; the PR only rewires feature-gate/controller flow.
Ote Binary Stdout Contract ✅ Passed No stdout writes appear in main/init/BeforeSuite paths; logger setup routes klog to stderr, and the changed files only use structured logging.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only e2e change is a return-value arity fix in an existing webhook test, with no IPv4 or external-network assumptions introduced.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or non-constant-time secret comparisons were added in the touched files.
Container-Privileges ✅ Passed No manifest files were changed, and the patch contains no privileged/security-context settings (privileged, hostPID/Network/IPC, allowPrivilegeEscalation, SYS_ADMIN).
No-Sensitive-Data-In-Logs ✅ Passed Changed logs only report platform/feature-gate state; no passwords, tokens, PII, or hostnames are logged in the touched files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign nrb 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

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 18, 2026
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 19, 2026
@mdbooth mdbooth changed the title OCPCLOUD 3541: Use feature gates consistently OCPCLOUD-3541: Use feature gates consistently Jun 19, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 19, 2026

Copy link
Copy Markdown

@mdbooth: This pull request references OCPCLOUD-3541 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.0.0" version, but no target version was set.

Details

In response to this:

This change removes various hard-coded assumptions in the code about which
platforms are supported and uses feature gates exclusively for feature
enablement. Specifically:

  • When ClusterAPIMachineMigration is enabled we now always run the operator,
    regardless of whether the platform has support.
  • Consequently we always install core CAPI, even if platform support is not yet
    enabled.
  • The revision controller now checks the per-platform feature gate before
    enabling any platform-specific profiles.
  • The machine-api-migration entrypoint now uses the MachineAPIMigration
    featuregate and the per-platform MachineAPIMigration instead of hard-coding
    AWS and OpenStack.

Summary by CodeRabbit

  • New Features

  • Added feature-gate–aware platform handling for revision component selection, filtering platform-scoped providers when gates are disabled.

  • Bug Fixes

  • ClusterOperator status is now consistently reported without an unsupported-platform-specific message.

  • Installer deployment reconciliation no longer branches on unsupported-platform deletion behavior.

  • Refactor

  • Machine API migration controller startup now only registers reconcilers when feature-gates and platform support allow it.

  • Chores

  • Updated OpenShift API dependencies.

  • Updated tests and webhook validations to match the updated infrastructure/platform type resolution behavior.

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 19, 2026
@mdbooth

mdbooth commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-disconnected-techpreview
/test e2e-aws-capi-techpreview
/test e2e-aws-capi-techpreview-post-install
/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-upgrade
/test e2e-azure-capi-techpreview
/test e2e-azure-ovn-techpreview
/test e2e-azure-ovn-techpreview-upgrade
/test e2e-gcp-capi-techpreview
/test e2e-gcp-ovn-techpreview
/test e2e-metal3-capi-techpreview
/test e2e-openstack-capi-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@mdbooth

mdbooth commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

/pipeline auto

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification

The pipeline-auto label has been added to this PR. Second-stage tests will be triggered automatically when all first-stage tests pass.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-disconnected-techpreview
/test e2e-aws-capi-techpreview
/test e2e-aws-capi-techpreview-post-install
/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-upgrade
/test e2e-azure-capi-techpreview
/test e2e-azure-ovn-techpreview
/test e2e-azure-ovn-techpreview-upgrade
/test e2e-gcp-capi-techpreview
/test e2e-gcp-ovn-techpreview
/test e2e-metal3-capi-techpreview
/test e2e-openstack-capi-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage.

@mdbooth

mdbooth commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

/test images

mdbooth added 2 commits July 28, 2026 15:39
The revision controller now checks platform-specific CAPI feature gates
when building the component list. Platform-specific provider profiles are
only included when the corresponding feature gate is enabled.
Remove the IsSupportedPlatform/SupportedPlatform guards from the
capi-operator entrypoint. The operator is deployed by CVO only when
the ClusterAPIMachineManagement feature gate is enabled, so all
controllers should run whenever the operator is deployed.

Platform-specific provider selection is handled independently by the
revision controller.
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-disconnected-techpreview
/test e2e-aws-capi-techpreview
/test e2e-aws-capi-techpreview-post-install
/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-upgrade
/test e2e-azure-capi-techpreview
/test e2e-azure-ovn-techpreview
/test e2e-azure-ovn-techpreview-upgrade
/test e2e-gcp-capi-techpreview
/test e2e-gcp-ovn-techpreview
/test e2e-metal3-capi-techpreview
/test e2e-openstack-capi-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@pmeida pmeida left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean refactor.
Just minor nits.

Comment thread pkg/util/featuregates.go Outdated

// IsMAPIMigrationEnabledForPlatform returns true if MAPI migration is enabled for the given
// platform in the given feature gates.
func IsMAPIMigrationEnabledForPlatform(platform configv1.PlatformType, featureGates featuregates.FeatureGate) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

IsCAPIEnabledForPlatform takes (featureGates, platform), but the new IsMAPIMigrationEnabledForPlatform takes (platform, featureGates). We can make the order consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just about worth a respin, I think.

Comment thread pkg/conversion/test/fuzz/fuzz.go Outdated
func(m *mapiv1beta1.MachineSetStatus, c randfill.Continue) {
c.FillNoCustom(m)

m.LabelSelector = "" // Ignore, this field. Both MAPI and CAPI (field is called 'selector') set this from spec.selector.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

The comma here creates an awkward read

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't believe a clanker would have written that, but I can't believe I would have written that either 😅 Gonna blame a clanker.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-disconnected-techpreview
/test e2e-aws-capi-techpreview
/test e2e-aws-capi-techpreview-post-install
/test e2e-aws-ovn-techpreview
/test e2e-aws-ovn-techpreview-upgrade
/test e2e-azure-capi-techpreview
/test e2e-azure-ovn-techpreview
/test e2e-azure-ovn-techpreview-upgrade
/test e2e-gcp-capi-techpreview
/test e2e-gcp-ovn-techpreview
/test e2e-metal3-capi-techpreview
/test e2e-openstack-capi-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@pmeida

pmeida commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@mdbooth: The following tests 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/e2e-aws-capi-disconnected-techpreview abd654c link false /test e2e-aws-capi-disconnected-techpreview
ci/prow/regression-clusterinfra-aws-ipi-techpreview-capi abd654c link false /test regression-clusterinfra-aws-ipi-techpreview-capi
ci/prow/e2e-aws-capi-techpreview abd654c link true /test e2e-aws-capi-techpreview

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

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. pipeline-auto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants