Skip to content

Conversation

@sunzhaohua2
Copy link
Contributor

@sunzhaohua2 sunzhaohua2 commented Dec 1, 2025

Summary by CodeRabbit

  • Tests
    • Added scenarios verifying MAPI Machine creation is blocked when a CAPI Machine with the same name exists.
    • Added scenarios verifying MAPI MachineSet creation is blocked when a CAPI MachineSet with the same name exists.
    • Activated a previously disabled test validating non-authoritative MAPI MachineSet provider spec mirrors authoritative values.
    • Added test helpers to assert expected failure behavior and error messages for these blocking cases.

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

@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 Dec 1, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 1, 2025

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

This pull request references OCPCLOUD-3188 which is a valid jira issue.

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 openshift-ci bot requested review from damdo and mdbooth December 1, 2025 08:25
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 1, 2025

[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 theobarberbany 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

@coderabbitai
Copy link

coderabbitai bot commented Dec 1, 2025

📝 Walkthrough

Walkthrough

Adds helpers and tests that assert MAPI Machine and MachineSet creation fail when a CAPI resource with the same name exists; also enables one previously-pending MachineSet spec.

Changes

Cohort / File(s) Summary
MAPI Machine failure helper & test
e2e/machine_migration_helpers.go, e2e/machine_migration_mapi_authoritative_test.go
Adds createSameNameMachineBlockedByVAPAuthMapi(...) which attempts to create a MAPI Machine with a given authoritativeAPI and expects creation to fail. Adds a test Context that creates a CAPI Machine first and asserts MAPI creation fails with the message "a Cluster API Machine with the same name already exists".
MAPI MachineSet failure helper & test
e2e/machineset_migration_helpers.go, e2e/machineset_migration_mapi_authoritative_test.go
Adds createSameNameMachineSetBlockedByVAPAuthMapi(...) to attempt MAPI MachineSet creation and assert failure. Replaces a pending PIt with an active It that uses this helper and expects "a Cluster API MachineSet with the same name already exists".
Enable previously-pending MachineSet test
e2e/machineset_migration_capi_authoritative_test.go
Converts a pending test (PIt) to an active test (It) validating that non-authoritative MAPI MachineSet providerSpec mirrors authoritative CAPI values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped to name a twin so bold,
Two names collided — the story told.
I stamp my paw and run the test,
The blocker wakes, the noise suppressed.
Bravo, order — tidy nest!

🚥 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 directly refers to adding e2e tests for ValidatingAdmissionPolicy, which matches the core changes adding test scenarios for MAPI Machine/MachineSet creation blocking and reactivating a disabled test.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% 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

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


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

@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 1, 2025

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

This pull request references OCPCLOUD-3188 which is a valid jira issue.

Details

In response to this:

Summary by CodeRabbit

  • Tests
  • Added new test scenarios to verify that MAPI Machine creation fails when a CAPI Machine with the same name already exists.
  • Added new test scenarios to verify that MAPI MachineSet creation fails when a CAPI MachineSet with the same name already exists.
  • Activated a previously disabled test for non-authoritative MAPI MachineSet provider specification validation.

✏️ 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: 0

🧹 Nitpick comments (5)
e2e/machineset_migration_capi_authoritative_test.go (1)

61-63: Enabling providerSpec mirror check looks correct

Activating this spec and asserting InstanceType on the MAPI providerSpec matches the authoritative CAPI MachineSet is consistent with the setup in this context and should give good signal on mirror correctness. If you want stronger coverage later, you could extend verifyMAPIMachineSetProviderSpec calls here to check a couple more key fields, but not required for this PR.

e2e/machineset_migration_helpers.go (1)

85-99: Failure helper is consistent with the success path; consider tightening error assertions

The helper mirrors createMAPIMachineSetWithAuthoritativeAPI nicely and gives a clear place to assert admission failures and expected messages. Two optional tweaks you might consider:

  • Assert on the error more directly, e.g. Expect(err).To(MatchError(ContainSubstring(expectedErrorMessage))), to couple the “must fail” and “message” expectations into a single check.
  • If you care about the failure class (e.g. validation vs conflict), you could also assert apierrors.IsInvalid(err)/IsForbidden(err) in addition to the substring to guard against unrelated failures.

Not blocking; current form is perfectly serviceable for these e2e tests.

e2e/machineset_migration_mapi_authoritative_test.go (1)

58-60: Name‑collision failure test is wired correctly

The scenario—pre‑create CAPI MachineSet, then assert MAPI MachineSet creation with the same name fails with the expected message via the helper—matches the intended admission behavior and keeps cleanup on the CAPI side only, which is appropriate for an expected failure.

If you end up adding more of these, you might factor the shared error substring ("a Cluster API MachineSet with the same name already exists") into a package‑level const to avoid brittle duplication, but this is fine as‑is.

e2e/machine_migration_helpers.go (1)

131-168: MAPI machine failure helper matches the existing patterns

This helper lines up well with createMAPIMachineWithAuthority: it selects a worker as a template, scrubs instance‑specific fields, applies the requested authority, and asserts that admission rejects the create with the expected message. That should give you a good place to centralize all “must fail” machine cases.

If you want to tighten it later, you could:

  • Use Expect(cl.Create(...)).To(MatchError(ContainSubstring(expectedErrorMessage))) to express the failure and message expectation in one go.
  • Optionally also assert on the error class (apierrors.IsInvalid/IsForbidden) to distinguish admission rejections from transport issues.

Not required for this PR.

e2e/machine_migration_mapi_authoritative_test.go (1)

32-50: Collision test between CAPI and MAPI Machines is well‑structured

Pre‑creating the CAPI Machine, then asserting that creating a MAPI Machine with the same name fails via createMAPIMachineExpectFailure cleanly exercises the VAP/validation behavior you care about. Cleanup only tracks the CAPI side here, which matches the “no MAPI created” expectation.

If you ever want extra defensiveness against unexpected admission behavior changes, you could extend the helper or this context to best‑effort clean up a successfully created MAPI Machine, but that’s a nice‑to‑have rather than a blocker.

📜 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 3d0f9cd and 5069190.

📒 Files selected for processing (5)
  • e2e/machine_migration_helpers.go (1 hunks)
  • e2e/machine_migration_mapi_authoritative_test.go (1 hunks)
  • e2e/machineset_migration_capi_authoritative_test.go (1 hunks)
  • e2e/machineset_migration_helpers.go (1 hunks)
  • e2e/machineset_migration_mapi_authoritative_test.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
e2e/machine_migration_helpers.go (2)
e2e/framework/machine.go (1)
  • GetMachines (18-44)
pkg/conversion/mapi2capi/interface.go (1)
  • Machine (24-26)
e2e/machineset_migration_helpers.go (1)
e2e/framework/machineset.go (1)
  • CreateMachineSet (49-94)
e2e/machine_migration_mapi_authoritative_test.go (1)
pkg/conversion/mapi2capi/interface.go (1)
  • Machine (24-26)

}

// createMAPIMachineExpectFailure attempts to create a MAPI Machine with specified authoritativeAPI and expects the creation to fail.
func createMAPIMachineExpectFailure(ctx context.Context, cl client.Client, machineName string, authority mapiv1beta1.MachineAuthority, expectedErrorMessage string) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit .. Can rename the function as createSameNameMachineBlockedByVAPAuthMapi it would convey exactly what the function is doing without checking its details ?

}

// createMAPIMachineSetExpectFailure attempts to create a MAPI MachineSet with specified authoritativeAPI and expects the creation to fail.
func createMAPIMachineSetExpectFailure(ctx context.Context, cl client.Client, replicas int, machineSetName string, machineSetAuthority mapiv1beta1.MachineAuthority, machineAuthority mapiv1beta1.MachineAuthority, expectedErrorMessage string) {
Copy link
Member

Choose a reason for hiding this comment

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

same comment as above for function name

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 19, 2026

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

This pull request references OCPCLOUD-3188 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

  • Tests
  • Added scenarios verifying MAPI Machine creation is blocked when a CAPI Machine with the same name exists.
  • Added scenarios verifying MAPI MachineSet creation is blocked when a CAPI MachineSet with the same name exists.
  • Activated a previously disabled test validating non-authoritative MAPI MachineSet provider specification mirrors authoritative values.

✏️ 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-robot
Copy link

openshift-ci-robot commented Jan 19, 2026

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

This pull request references OCPCLOUD-3188 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

  • Tests
  • Added scenarios verifying MAPI Machine creation is blocked when a CAPI Machine with the same name exists.
  • Added scenarios verifying MAPI MachineSet creation is blocked when a CAPI MachineSet with the same name exists.
  • Activated a previously disabled test validating non-authoritative MAPI MachineSet provider spec mirrors authoritative values.
  • Added test helpers to assert expected failure behavior and error messages for these blocking cases.

✏️ 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.

@sunzhaohua2
Copy link
Contributor Author

/test e2e-aws-capi-techpreview

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 20, 2026

@sunzhaohua2: 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

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.

3 participants