Skip to content

SPLAT-2854: Fixing issue related to unintended VAP interactions#1518

Open
vr4manta wants to merge 1 commit into
openshift:mainfrom
vr4manta:SPLAT-2854
Open

SPLAT-2854: Fixing issue related to unintended VAP interactions#1518
vr4manta wants to merge 1 commit into
openshift:mainfrom
vr4manta:SPLAT-2854

Conversation

@vr4manta

@vr4manta vr4manta commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

SPLAT-2854

Changes

  • Added additional controls to vSphere VAP to reduce unnecessary calls

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation policy behavior for vSphere failure-domain protections by applying equivalent resource matching.
    • Ensures validation rules consistently cover equivalent API resource versions during updates.

@openshift-ci-robot

openshift-ci-robot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@vr4manta: This pull request references SPLAT-2854 which is a valid jira issue.

Details

In response to this:

SPLAT-2854

Changes

  • Added additional controls to vSphere VAP to reduce unnecessary calls

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 Jul 15, 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 Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 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

@coderabbitai

coderabbitai Bot commented Jul 15, 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

Adds a reusable helper for the Equivalent admission match policy and applies it to the three vSphere failure-domain ValidatingAdmissionPolicy constructors.

Changes

VAP match policy configuration

Layer / File(s) Summary
Configure equivalent resource matching
pkg/webhooks/vap.go
Adds matchPolicyEquivalent() and assigns its result to the match constraints of the Machines, ControlPlaneMachineSets, and MachineSets policies.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR's focus on reducing unintended vSphere VAP interactions and is specific enough for history scanning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 PASS: PR only changes pkg/webhooks/vap.go policy config; no Ginkgo tests or titles were added or modified.
Test Structure And Quality ✅ Passed PR only changes pkg/webhooks/vap.go; no Ginkgo test files or test logic were modified, so the test-quality check is not applicable.
Microshift Test Compatibility ✅ Passed No Ginkgo/e2e tests were added; only pkg/webhooks/vap.go changed, and it contains no test code or MicroShift-specific assumptions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only pkg/webhooks/vap.go changed; it adds VAP match-policy wiring, with no Ginkgo test files or SNO-relevant test patterns added.
Topology-Aware Scheduling Compatibility ✅ Passed Patch only adds VAP MatchPolicy/selector matching for infrastructure updates; no pod scheduling, replicas, affinity, or topology logic changed.
Ote Binary Stdout Contract ✅ Passed Only pkg/webhooks/vap.go changed, and it adds policy builders with no init/main/TestMain/RunSpecs code or stdout/log writes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Only pkg/webhooks/vap.go changed; no new Ginkgo e2e tests or IPv4/public-network assumptions were added.
No-Weak-Crypto ✅ Passed The only change adds MatchPolicy=Equivalent and selectors in VAP constructors; no weak algorithms, custom crypto, or secret comparisons are present.
Container-Privileges ✅ Passed PR only updates pkg/webhooks/vap.go; no container/K8s manifests or privileged settings were added.
No-Sensitive-Data-In-Logs ✅ Passed No logging was added in pkg/webhooks/vap.go; the change only sets VAP match policy and validation messages, with no passwords/tokens/PII emitted.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (2)
test/e2e/vsphere/failure_domain_vap.go (2)

236-236: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Use a bounded, cancellable context for the suite.

context.Background() cannot expire or be canceled, so a blocked Kubernetes request can stall this serial suite. Use a per-spec context with cancellation or a deadline.

As per path instructions, Go code must use context.Context for cancellation and timeouts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/vsphere/failure_domain_vap.go` at line 236, Replace
context.Background() in the suite setup with a per-spec context.Context that has
cancellation or a deadline, and ensure the cancel function is invoked during
spec cleanup. Propagate this bounded context through the suite’s Kubernetes
operations so blocked requests can terminate without changing the serial
execution behavior.

Source: Path instructions


281-304: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert that the deployed policies use Equivalent matching.

These checks only verify existence, and every update below uses config.openshift.io/v1, so the suite still passes if MatchPolicy reverts to its default. Assert each returned VAP's Spec.MatchConstraints.MatchPolicy, or add equivalent constructor assertions in pkg/webhooks/vap_test.go.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/vsphere/failure_domain_vap.go` around lines 281 - 304, Update the
VAP deployment test in the “should have three VAPs and three bindings deployed”
case to retain each returned ValidatingAdmissionPolicy and assert its
Spec.MatchConstraints.MatchPolicy is Equivalent. Apply this to the Machine,
CPMS, and MachineSet policies while preserving the existing existence checks;
binding assertions do not need this validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/e2e/vsphere/failure_domain_vap.go`:
- Around line 140-158: Update the failure-domain selection logic around the
firstMatch fallback to return false when no CPMS-only failure domain can be
isolated. Remove the fallback that returns a worker-shared failure domain, so
downstream rejection continues to identify ControlPlaneMachineSet as the failure
reason.
- Around line 500-521: Update the failure-domain selection logic around the fd
candidate loop to also exclude domains referenced by existing MachineSets.
Inspect each MachineSet’s failure-domain region and zone labels, mark matching
candidates as used, and only assign fd when no Machine, CPMS, or MachineSet
references it.
- Around line 379-390: Register a DeferCleanup restoration before the
Infrastructure mutation in the failure-domain test, before the Update call in
the removal flow. Ensure the cleanup re-fetches the current Infrastructure and
restores infra.Spec.PlatformSpec.VSphere.FailureDomains even if the subsequent
GET or restore update fails, matching the existing mutation-test cleanup
pattern; then retain the explicit restoration path as appropriate.
- Around line 491-498: Update the CPMS lookup in the failure-domain selection
flow to treat only an apierrors.IsNotFound(cpmsErr) result as an absent CPMS;
for every other non-nil error, assert or fail immediately instead of continuing
as though no CPMS exists. Preserve the existing FailureDomains processing when
the lookup succeeds.
- Around line 426-431: Update the MachineSet cleanup in DeferCleanup to wait
until the deleted testMS is confirmed absent. After issuing Delete, poll the
same MachineSets resource using the existing context and testMS.Name until the
Get result returns apierrors.IsNotFound; preserve warning logs for unexpected
deletion or polling errors.
- Around line 70-72: Remove the single-failure-domain shortcut in the
failure-domain lookup logic that returns fds[0] when len(fds) == 1. Let the
existing region/zone label matching determine whether the Machine VAP applies,
so unlabeled single-FD Machines are not treated as VAP references.

---

Nitpick comments:
In `@test/e2e/vsphere/failure_domain_vap.go`:
- Line 236: Replace context.Background() in the suite setup with a per-spec
context.Context that has cancellation or a deadline, and ensure the cancel
function is invoked during spec cleanup. Propagate this bounded context through
the suite’s Kubernetes operations so blocked requests can terminate without
changing the serial execution behavior.
- Around line 281-304: Update the VAP deployment test in the “should have three
VAPs and three bindings deployed” case to retain each returned
ValidatingAdmissionPolicy and assert its Spec.MatchConstraints.MatchPolicy is
Equivalent. Apply this to the Machine, CPMS, and MachineSet policies while
preserving the existing existence checks; binding assertions do not need this
validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a3a488a1-ed58-4124-8ce9-77fe7b798e54

📥 Commits

Reviewing files that changed from the base of the PR and between c0b2d2c and aa3328c.

📒 Files selected for processing (2)
  • pkg/webhooks/vap.go
  • test/e2e/vsphere/failure_domain_vap.go

Comment thread test/e2e/vsphere/failure_domain_vap.go Outdated
Comment thread test/e2e/vsphere/failure_domain_vap.go Outdated
Comment thread test/e2e/vsphere/failure_domain_vap.go Outdated
Comment thread test/e2e/vsphere/failure_domain_vap.go Outdated
Comment thread test/e2e/vsphere/failure_domain_vap.go Outdated
Comment thread test/e2e/vsphere/failure_domain_vap.go Outdated
@vr4manta
vr4manta force-pushed the SPLAT-2854 branch 2 times, most recently from bf1b8d2 to 556cc26 Compare July 16, 2026 11:32
jcpowermac added a commit to jcpowermac/testing-day2-vcenter that referenced this pull request Jul 16, 2026
Detects spurious VAP updates caused by nil vs server-defaulted field
diffs in resourceapply. Asserts resourceVersion stability across 6 MAO
sync cycles — fails before openshift/machine-api-operator#1518, passes
after.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/webhooks/vap.go (1)

44-47: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for MatchPolicy: Equivalent.

The constructors now depend on this setting, but the existing tests in pkg/webhooks/vap_test.go do not assert it. Add an assertion for all three policies so a future refactor cannot silently revert to exact matching.

Also applies to: 72-74, 183-185, 290-292

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/webhooks/vap.go` around lines 44 - 47, Add regression assertions in
pkg/webhooks/vap_test.go for all three policy constructors, verifying each sets
MatchPolicy to Equivalent. Cover the constructors associated with the referenced
locations and preserve the existing test structure while ensuring a future
change cannot revert them to exact matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/webhooks/vap.go`:
- Around line 44-47: Add regression assertions in pkg/webhooks/vap_test.go for
all three policy constructors, verifying each sets MatchPolicy to Equivalent.
Cover the constructors associated with the referenced locations and preserve the
existing test structure while ensuring a future change cannot revert them to
exact matching.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 982a7a0a-e133-4c2f-9be9-ebea1f38e4a2

📥 Commits

Reviewing files that changed from the base of the PR and between bf1b8d2 and 391b9ec.

📒 Files selected for processing (1)
  • pkg/webhooks/vap.go

@jcpowermac

Copy link
Copy Markdown
Contributor

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jcpowermac: This PR has been marked as verified by @jcpowermac via integration testing. https://github.com/jcpowermac/testing-day2-vcenter/blob/main/docs/tests/N-SEQ-08.md.

Details

In response to this:

/verified by @jcpowermac via integration testing. https://github.com/jcpowermac/testing-day2-vcenter/blob/main/docs/tests/N-SEQ-08.md

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.

@vr4manta
vr4manta marked this pull request as ready for review July 16, 2026 13:34
@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 Jul 16, 2026
@openshift-ci
openshift-ci Bot requested review from damdo and nrb July 16, 2026 13:35
@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

@vr4manta

Copy link
Copy Markdown
Contributor Author

/test ?

@vr4manta

Copy link
Copy Markdown
Contributor Author

/test e2e-vsphere-ovn e2e-vsphere-ovn-multi-vcenter

@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

@nrb

nrb commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

/lgtm
/approve
/verified by CI
/label acknowledge-critical-fixes-only

@openshift-ci openshift-ci Bot added the acknowledge-critical-fixes-only Indicates if the issuer of the label is OK with the policy. label Jul 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@nrb: This PR has been marked as verified by CI.

Details

In response to this:

/lgtm
/approve
/verified by CI
/label acknowledge-critical-fixes-only

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 Jul 16, 2026
@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nrb

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 16, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD c0b2d2c and 2 for PR HEAD fdf3d83 in total

@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 417ad2f and 1 for PR HEAD fdf3d83 in total

@vr4manta

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@vr4manta: 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/e2e-metal-ipi fdf3d83 link true /test e2e-metal-ipi

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

acknowledge-critical-fixes-only Indicates if the issuer of the label is OK with the policy. 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. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants