Skip to content

OCPCLOUD-3262: MAPI & CAPI MachineSet VAP#440

Open
theobarberbany wants to merge 5 commits intoopenshift:mainfrom
theobarberbany:tb/3262
Open

OCPCLOUD-3262: MAPI & CAPI MachineSet VAP#440
theobarberbany wants to merge 5 commits intoopenshift:mainfrom
theobarberbany:tb/3262

Conversation

@theobarberbany
Copy link
Contributor

@theobarberbany theobarberbany commented Jan 7, 2026

Summary by CodeRabbit

  • New Features

    • Expanded admission validations to protect additional cluster labels/annotations (including cluster.x-k8s.io/* and clusters.x-k8s.io/*), added new admission policies/bindings to enforce MAPI↔CAPI mirroring, machineset gating, and updated validation/warning messages for authoritative-source and sync scenarios.
  • Tests

    • Added extensive unit and e2e coverage for creation/update restrictions, protected labels/annotations, authoritative-source transitions (now template-aware ordering), and machineset/machine synchronization behaviors; standardized protected-message assertions.

@openshift-ci-robot
Copy link

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 Jan 7, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 7, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 7, 2026

@theobarberbany: This pull request references OCPCLOUD-3262 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 either version "4.22." or "openshift-4.22.", but it targets "openshift-4.21" instead.

Details

In response to this:

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
Copy link
Contributor

openshift-ci bot commented Jan 7, 2026

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Adds new ValidatingAdmissionPolicy and Binding resources to enforce and mirror authoritativeAPI transitions, expands protected label/annotation namespaces to include cluster.x-k8s.io/*, and updates unit and e2e tests and helpers to separate and verify template vs. spec authoritative switching and sync behavior.

Changes

Cohort / File(s) Summary
Admission policy manifests
manifests/0000_30_cluster-api_09_admission-policies.yaml
Added multiple ValidatingAdmissionPolicy and ValidatingAdmissionPolicyBinding resources (machine-api-machine-set-vap, cluster-api-machine-set-vap, etc.) that enforce/mirror spec.status.authoritativeAPI, add parameter handling, expand protected label/annotation scopes to include cluster.x-k8s.io/* and clusters.x-k8s.io/*, and add creation/update gating and authorization-sync checks.
MachineSet VAP unit tests
pkg/controllers/machinesetsync/machineset_vap_test.go
Large new test contexts validating prevention of non-authoritative edits on MAPI and CAPI MachineSets, protected label/annotation enforcement, spec vs. template authoritative transitions, and sync-controller-only mutation behavior.
MachineSet sync controller tests
pkg/controllers/machinesetsync/machineset_sync_controller_test.go
Two test expectation string updates swapping synchronization direction text in assertions.
Machine sync controller tests (messages)
pkg/controllers/machinesync/machine_sync_controller_test.go
Introduced errMsgProtectedLabels and errMsgProtectedAnnotations constants and replaced inline protected-label/annotation assertion substrings with these constants.
e2e messages & constants
e2e/machine_migration_vap_tests.go
Updated vapProtectedLabelMessage and vapProtectedAnnotationMessage to include cluster.x-k8s.io/* and clusters.x-k8s.io/* in protected sets; newline added.
e2e authoritative helpers & tests
e2e/machineset_migration_helpers.go, e2e/machineset_migration_capi_authoritative_test.go, e2e/machineset_migration_mapi_authoritative_test.go
Split authoritative updates into two functions: switchMachineSetAuthoritativeAPI (now updates top-level spec.authoritativeAPI only) and new switchMachineSetTemplateAuthoritativeAPI (updates spec.template.spec.authoritativeAPI); updated call sites and reordered test flows to include template-aware switching and explicit verification steps.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant API_Server
  participant VAP as ValidatingAdmissionPolicy
  participant SyncController
  participant MAPI
  participant CAPI

  User->>API_Server: create/update Machine or MachineSet
  API_Server->>VAP: evaluate applicable policies/bindings
  VAP-->>API_Server: allow / deny (policy message)
  alt allowed
    API_Server->>MAPI: persist MAPI resource (if applicable)
    API_Server->>CAPI: persist CAPI resource (if applicable)
    MAPI->>SyncController: enqueue/reconcile
    CAPI->>SyncController: enqueue/reconcile
    SyncController->>MAPI: apply sync mutations when authoritative
    SyncController->>CAPI: apply sync mutations when authoritative
  else denied
    API_Server-->>User: rejection response (policy error)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐇
I nibble labels, guard the night,
Templates flip, then hop in light,
CAPI, MAPI keep in tune,
Policies hum beneath the moon,
Tests clap paws — a carrot bright 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Validating Admission Policies (VAPs) for MachineSet resources for both MAPI and CAPI.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


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

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 8, 2026
@theobarberbany theobarberbany marked this pull request as ready for review January 9, 2026 14:03
@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 Jan 9, 2026
@theobarberbany theobarberbany marked this pull request as draft January 9, 2026 14:03
@openshift-ci openshift-ci bot requested review from damdo and mdbooth January 9, 2026 14:03
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 9, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 9, 2026

@theobarberbany: This pull request references OCPCLOUD-3262 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 either version "4.22." or "openshift-4.22.", but it targets "openshift-4.21" instead.

Details

In response to this:

Summary by CodeRabbit

  • New Features
  • Added comprehensive validation controls for machine resource management to prevent invalid configurations and unsupported field combinations
  • Enforced stricter consistency requirements between different machine management systems during resource creation and updates
  • Introduced protective constraints on critical machine resource attributes

✏️ Tip: You can customize this high-level summary in your review settings.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @manifests/0000_30_cluster-api_09_admission-policies.yaml:
- Around line 245-271: The error messages are missing protected prefixes
referenced by the validation expressions; update the message for the label guard
(the rule guarding variables.newLabels/oldLabels in the expression that checks
startsWith('machine.openshift.io'), startsWith('kubernetes.io') and
contains('cluster.x-k8s.io/')) to include "cluster.x-k8s.io/*" alongside
"machine.openshift.io/*" and "kubernetes.io/*", and update the annotation guard
message (the rule using variables.newAnn/oldAnn that checks
startsWith('machine.openshift.io') and
contains('cluster.x-k8s.io'/'clusters.x-k8s.io')) to mention both
"cluster.x-k8s.io/*" and "clusters.x-k8s.io/*" in addition to
"machine.openshift.io/*"; mirror the wording used in the
cluster-api-machine-set-vap policy messages for consistency.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 2d56218 and b944df0.

📒 Files selected for processing (4)
  • manifests/0000_30_cluster-api_09_admission-policies.yaml
  • pkg/controllers/machinesetsync/machineset_vap_test.go
  • pkg/controllers/machinesync/__debug_bin2952830453
  • pkg/controllers/machinesync/__debug_bin4126191047
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/controllers/machinesetsync/machineset_vap_test.go (2)
pkg/conversion/mapi2capi/interface.go (1)
  • MachineSet (29-31)
pkg/admissionpolicy/testutils/util.go (3)
  • AddSentinelValidation (185-190)
  • UpdateVAPBindingNamespaces (216-239)
  • VerifySentinelValidation (193-197)
🪛 Gitleaks (8.30.0)
pkg/controllers/machinesetsync/machineset_vap_test.go

[high] 428-428: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 440-440: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 681-681: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


[high] 693-693: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (9)
pkg/controllers/machinesetsync/machineset_vap_test.go (6)

50-50: LGTM!

Good refactoring to extract capiMachineSetBuilder as a reusable builder variable. This improves readability and allows the builder to be configured differently across test contexts.

Also applies to: 102-108


427-435: Static analysis false positive: cluster name mistaken for API key.

Gitleaks flags ci-op-gs2k97d6-c9e33-2smph as a "Generic API Key", but this is an OpenShift CI-generated cluster identifier used in test fixtures. This is a false positive and can be safely ignored.

The test setup for creating MAPI and CAPI MachineSet pairs with appropriate labels and annotations looks correct for validating the policy behavior.

Also applies to: 439-448


451-468: LGTM!

Correct test logic: when status.AuthoritativeAPI is MachineAPI, spec changes should be permitted since MAPI is the source of truth.


470-600: LGTM!

Comprehensive test coverage for the ClusterAPI-authoritative scenario:

  • Correctly verifies spec fields (except authoritativeAPI) are locked
  • Validates protection of machine.openshift.io/* labels and annotations
  • Tests the param-controlled label synchronization logic

603-706: LGTM!

Good parallel test structure for CAPI MachineSet validation. The setup correctly:

  • Configures the VAP binding with MAPI as param source and CAPI as target
  • Sets status.AuthoritativeAPI on the MAPI MachineSet (as the param)
  • Includes cluster.x-k8s.io/cluster-name label in CAPI MachineSet fixtures for testing CAPI-specific label protection

The cluster identifiers flagged by Gitleaks (lines 681, 693) are the same false positives noted earlier.


707-835: LGTM!

Thorough test coverage for CAPI MachineSet behavior when Machine API is authoritative:

  • Verifies spec changes are blocked on the CAPI side
  • Tests cluster.x-k8s.io/* label protections (lines 762-772)
  • Validates param-controlled label synchronization from MAPI to CAPI
manifests/0000_30_cluster-api_09_admission-policies.yaml (3)

161-177: LGTM!

The binding configuration is correct:

  • parameterNotFoundAction: Allow ensures MAPI functionality isn't blocked when no CAPI MachineSet exists
  • Namespace targeting and param references are appropriate

394-410: LGTM!

Correct binding configuration with appropriate namespace targeting and param source inversion from the MAPI binding.


412-499: LGTM!

The CAPI MachineSet policy is well-structured:

  • Correctly checks authoritativeAPI from the MAPI param (line 441)
  • Uses simpler object.spec == oldObject.spec comparison (line 460) since CAPI MachineSets don't have an authoritativeAPI field to exclude
  • Error messages are complete and accurate

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 9, 2026
@theobarberbany theobarberbany marked this pull request as ready for review January 9, 2026 15:10
@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 Jan 9, 2026
@theobarberbany theobarberbany marked this pull request as draft January 9, 2026 15:10
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 9, 2026
@openshift-ci openshift-ci bot requested a review from racheljpg January 9, 2026 15:12
@theobarberbany theobarberbany force-pushed the tb/3262 branch 2 times, most recently from 5a2249b to a70db0b Compare January 9, 2026 15:37
@theobarberbany theobarberbany marked this pull request as ready for review January 9, 2026 15:37
@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 Jan 9, 2026
@openshift-ci openshift-ci bot requested a review from nrb January 9, 2026 15:38
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 9, 2026

@theobarberbany: This pull request references OCPCLOUD-3262 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 either version "4.22." or "openshift-4.22.", but it targets "openshift-4.21" instead.

Details

In response to this:

Summary by CodeRabbit

  • New Features
  • Added comprehensive admission validations to prevent unsupported or conflicting machine/machineset configurations and enforce authoritative-source constraints.
  • Strengthened label/annotation protections and param-driven label synchronization rules across machine management systems.
  • Tests
  • Added extensive tests covering creation/update restrictions and authoritative-source behaviors for machines and machinesets.
  • Updated synchronization test expectations to reflect direction semantics.

✏️ Tip: You can customize this high-level summary in your review settings.

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 the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2026
@openshift-ci-robot
Copy link

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-techpreview
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/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-openstack-ovn-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@e2e/machine_migration_vap_tests.go`:
- Around line 32-35: The test's expected VAP annotation error string
(vapProtectedAnnotationMessage) is out of date; update the
vapProtectedAnnotationMessage constant to match the current policy text by
including both "cluster.x-k8s.io/*" and "clusters.x-k8s.io/*" patterns (i.e.,
change the string assigned to vapProtectedAnnotationMessage so it reads the
full, updated policy message exactly as the policy returns).

In `@e2e/machineset_migration_helpers.go`:
- Around line 93-99: The failure message in
switchMachineSetTemplateAuthoritativeAPI contains a typo ("tempplate"); update
the fmt string passed to Eventually(...).Should(...) to correct "tempplate" to
"template" so the error reads "Failed to update MachineSet %s template
AuthoritativeAPI", keeping the same mapiMachineSet.Name interpolation and
leaving function logic and identifiers
(switchMachineSetTemplateAuthoritativeAPI, mapiMachineSet, machineAuthority)
unchanged.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 2, 2026

@theobarberbany: This pull request references OCPCLOUD-3262 which is a valid jira issue.

Details

In response to this:

Summary by CodeRabbit

  • New Features
  • Expanded admission validations to protect additional cluster labels/annotations (including cluster.x-k8s.io/*), added policy bindings to enforce MAPI/CAPI mirroring, machineset-specific gating, and updated validation/warning messages for authoritative-source and sync scenarios.
  • Tests
  • Added extensive unit and e2e coverage for creation/update restrictions, protected labels/annotations, authoritative-source transitions (including template-aware authoritative switches), and machineset/machine synchronization semantics.

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.

@JoelSpeed
Copy link
Contributor

/lgtm

@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 2, 2026

@theobarberbany: This pull request references OCPCLOUD-3262 which is a valid jira issue.

Details

In response to this:

Summary by CodeRabbit

  • New Features
  • Strengthened admission validations to protect additional cluster labels/annotations (including cluster.x-k8s.io/*), added new admission policies/bindings to enforce MAPI↔CAPI mirroring, machineset-specific gating, and updated validation/warning messages for authoritative-source and sync scenarios.
  • Tests
  • Added extensive unit and e2e coverage for creation/update restrictions, protected labels/annotations, authoritative-source transitions (now including template-aware authoritative switches), and machineset/machine synchronization behaviors.

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 the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2026
@openshift-ci-robot
Copy link

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-techpreview
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/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-openstack-ovn-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@sunzhaohua2
Copy link
Contributor

when creaing a machineset .spec.authoritativeAPI:MachineAPI and .spec.template.spec.authoritative:MachineAPI, just change spec.authoritativeAPI to ClusterAPI, report FailedToUpdateMAPIMachineSet error.

Or creating a machineset, just set spec.authoritativeAPI:ClusterAPI, remove spec.template.spec.authoritative, report same error.

$ oc get machineset.m ci-ln-kpgi9sk-76ef8-lgrcr-worker-us-east-2b -o yaml                                                                                                                        
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata:
  annotations:
    capacity.cluster-autoscaler.kubernetes.io/labels: kubernetes.io/arch=amd64
    machine.openshift.io/GPU: "0"
    machine.openshift.io/memoryMb: "16384"
    machine.openshift.io/vCPU: "4"
  creationTimestamp: "2026-02-02T13:54:46Z"
  finalizers:
  - sync.machine.openshift.io/finalizer
  generation: 2
  labels:
    machine.openshift.io/cluster-api-cluster: ci-ln-kpgi9sk-76ef8-lgrcr
  name: ci-ln-kpgi9sk-76ef8-lgrcr-worker-us-east-2b
  namespace: openshift-machine-api
  resourceVersion: "66771"
  uid: bf2b68b1-d87e-4066-abd0-c75c297cda5d
spec:
  authoritativeAPI: ClusterAPI
  replicas: 2
  selector:
    matchLabels:
      machine.openshift.io/cluster-api-cluster: ci-ln-kpgi9sk-76ef8-lgrcr
      machine.openshift.io/cluster-api-machineset: ci-ln-kpgi9sk-76ef8-lgrcr-worker-us-east-2b
  template:
    metadata:
      labels:
        machine.openshift.io/cluster-api-cluster: ci-ln-kpgi9sk-76ef8-lgrcr
        machine.openshift.io/cluster-api-machine-role: worker
        machine.openshift.io/cluster-api-machine-type: worker
        machine.openshift.io/cluster-api-machineset: ci-ln-kpgi9sk-76ef8-lgrcr-worker-us-east-2b
    spec:
      authoritativeAPI: MachineAPI
      lifecycleHooks: {}
      metadata: {}
      providerSpec:
        value:
          ami:
            id: ami-0bc8dda494f111572
          apiVersion: machine.openshift.io/v1beta1
          blockDevices:
          - ebs:
              encrypted: true
              iops: 0
              kmsKey:
                arn: ""
              volumeSize: 120
              volumeType: gp3
          capacityReservationId: ""
          credentialsSecret:
            name: aws-cloud-credentials
          deviceIndex: 0
          iamInstanceProfile:
            id: ci-ln-kpgi9sk-76ef8-lgrcr-worker-profile
          instanceType: m6a.xlarge
          kind: AWSMachineProviderConfig
          metadata: {}
          metadataServiceOptions: {}
          placement:
            availabilityZone: us-east-2b
            region: us-east-2
          securityGroups:
          - filters:
            - name: tag:Name
              values:
              - ci-ln-kpgi9sk-76ef8-lgrcr-node
          - filters:
            - name: tag:Name
              values:
              - ci-ln-kpgi9sk-76ef8-lgrcr-lb
          subnet:
            filters:
            - name: tag:Name
              values:
              - ci-ln-kpgi9sk-76ef8-lgrcr-subnet-private-us-east-2b
          tags:
          - name: kubernetes.io/cluster/ci-ln-kpgi9sk-76ef8-lgrcr
            value: owned
          - name: ci-nat-replace
            value: "true"
          - name: clusterName
            value: ci-ln-kpgi9sk-76ef8
          - name: expirationDate
            value: 2026-02-02T21:39+00:00
          userDataSecret:
            name: worker-user-data
status:
  authoritativeAPI: ClusterAPI
  availableReplicas: 2
  conditions:
  - lastTransitionTime: "2026-02-02T15:56:35Z"
    message: The AuthoritativeAPI status is set to 'ClusterAPI'
    reason: AuthoritativeAPINotMachineAPI
    status: "True"
    type: Paused
  - lastTransitionTime: "2026-02-02T15:56:35Z"
    message: 'failed to update MAPI machine set: machinesets.machine.openshift.io
      "ci-ln-kpgi9sk-76ef8-lgrcr-worker-us-east-2b" is forbidden: ValidatingAdmissionPolicy
      ''machine-api-machine-set-vap'' with binding ''machine-api-machine-set-vap''
      denied request: You may only modify spec.authoritativeAPI. Any other change
      inside .spec is not allowed. This is because status.authoritativeAPI is set
      to Cluster API.'
    reason: FailedToUpdateMAPIMachineSet
    severity: Error
    status: "False"
    type: Synchronized
  fullyLabeledReplicas: 2
  observedGeneration: 2
  readyReplicas: 2
  replicas: 2
  synchronizedGeneration: 0

Locally seeing regular flake where we reconcile fast enough that we
don't get the intermediary 'sync'd MAPI to CAPI' before we update to the
stable state of 'sync'd CAPI to MAPI' we expect to see given the
AuthoritativeAPI
Updates the protected labels and annotations messages for the CAPI and
MAPI machine vaps to include all blocked prefixes.
This change splits changing the machineset.spec.AuthoritativeAPI from
the changing of the machineset.spec.template.spec.AuthoritativeAPI.

This is to handle the new CAPI & MAPI MachineSet VAPs
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
@theobarberbany
Copy link
Contributor Author

/test e2e-aws-capi-techpreview

@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 3, 2026

@theobarberbany: This pull request references OCPCLOUD-3262 which is a valid jira issue.

Details

In response to this:

Summary by CodeRabbit

  • New Features

  • Expanded admission validations to protect additional cluster labels/annotations (including cluster.x-k8s.io/* and clusters.x-k8s.io/*), added new admission policies/bindings to enforce MAPI↔CAPI mirroring, machineset gating, and updated validation/warning messages for authoritative-source and sync scenarios.

  • Tests

  • Added extensive unit and e2e coverage for creation/update restrictions, protected labels/annotations, authoritative-source transitions (now template-aware ordering), and machineset/machine synchronization behaviors; standardized protected-message assertions.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@manifests/0000_30_cluster-api_09_admission-policies.yaml`:
- Around line 225-238: The immutability check in the expression named
specLockedExceptAuthoritativeAPI is missing the authoritativeAPI field; update
the array inside specLockedExceptAuthoritativeAPI to include
[object.spec.?authoritativeAPI, oldObject.spec.?authoritativeAPI] alongside the
existing entries so authoritativeAPI is compared the same way as
replicas/minReadySeconds/deletePolicy/selector/template, or alternatively add an
explicit comment explaining why authoritativeAPI is intentionally excluded;
locate the specLockedExceptAuthoritativeAPI expression and add the
authoritativeAPI tuple to the checked list to enforce immutability.

@sunzhaohua2
Copy link
Contributor

sunzhaohua2 commented Feb 4, 2026

Retest this, change spec.authoritativeAPI from MachineAPI to ClusterAPI work as expected.

spec:
  authoritativeAPI: ClusterAPI
  deletePolicy: Random
  replicas: 1
  selector:
    matchLabels:
      machine.openshift.io/cluster-api-cluster: ci-ln-l876w1k-76ef8-wpqzz
      machine.openshift.io/cluster-api-machineset: ci-ln-l876w1k-76ef8-wpqzz-worker-us-east-1f
  template:
    metadata:
      labels:
        machine.openshift.io/cluster-api-cluster: ci-ln-l876w1k-76ef8-wpqzz
        machine.openshift.io/cluster-api-machine-role: worker
        machine.openshift.io/cluster-api-machine-type: worker
        machine.openshift.io/cluster-api-machineset: ci-ln-l876w1k-76ef8-wpqzz-worker-us-east-1f
    spec:
      authoritativeAPI: MachineAPI
...
status:
  authoritativeAPI: ClusterAPI
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2026-02-03T14:02:16Z"
    message: The AuthoritativeAPI status is set to 'ClusterAPI'
    reason: AuthoritativeAPINotMachineAPI
    status: "True"
    type: Paused
  - lastTransitionTime: "2026-02-03T14:02:16Z"
    message: Successfully synchronized CAPI MachineSet to MAPI
    reason: ResourceSynchronized
    severity: ""
    status: "True"
    type: Synchronized
  fullyLabeledReplicas: 1
  observedGeneration: 3
  readyReplicas: 1
  replicas: 1
  synchronizedGeneration: 2

Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

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

/pipeline required

Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 4, 2026
@openshift-ci-robot
Copy link

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

@damdo
Copy link
Member

damdo commented Feb 4, 2026

/pipeline required

@openshift-ci-robot
Copy link

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-capi-techpreview
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/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-openstack-ovn-techpreview
/test e2e-vsphere-capi-techpreview
/test regression-clusterinfra-aws-ipi-techpreview-capi

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 4, 2026

@theobarberbany: 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-gcp-capi-techpreview 9bae54e link true /test e2e-gcp-capi-techpreview
ci/prow/e2e-aws-ovn-techpreview 9bae54e link true /test e2e-aws-ovn-techpreview
ci/prow/e2e-aws-ovn 9bae54e link true /test e2e-aws-ovn
ci/prow/e2e-azure-ovn-techpreview 9bae54e link false /test e2e-azure-ovn-techpreview
ci/prow/e2e-gcp-ovn-techpreview 9bae54e link true /test e2e-gcp-ovn-techpreview
ci/prow/e2e-aws-capi-techpreview 9bae54e link true /test e2e-aws-capi-techpreview
ci/prow/regression-clusterinfra-aws-ipi-techpreview-capi 9bae54e link false /test regression-clusterinfra-aws-ipi-techpreview-capi
ci/prow/e2e-openstack-ovn-techpreview 9bae54e link true /test e2e-openstack-ovn-techpreview
ci/prow/e2e-aws-ovn-serial-1of2 9bae54e link true /test e2e-aws-ovn-serial-1of2

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants