Skip to content

OCPBUGS-101813: only block vSphere machine deletion for VMDK-backed v… - #1528

Draft
jcpowermac wants to merge 2 commits into
openshift:mainfrom
jcpowermac:ocpbugs-101813-volume-type-filtering
Draft

OCPBUGS-101813: only block vSphere machine deletion for VMDK-backed v…#1528
jcpowermac wants to merge 2 commits into
openshift:mainfrom
jcpowermac:ocpbugs-101813-volume-type-filtering

Conversation

@jcpowermac

@jcpowermac jcpowermac commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

…olumes

The nodeHasVolumesAttached() check was volume-type-agnostic, blocking machine deletion for any attached volume. This caused indefinite blocking when non-VMDK volumes (NFS, iSCSI, etc.) were attached, since DaemonSet pods with these volumes remain Running and never get evicted.

The VMDK data loss risk only applies to vSphere-backed volumes. This change filters by VolumeAttachment.Spec.Attacher to only block for:

  • csi.vsphere.vmware.com (vSphere CSI)
  • kubernetes.io/vsphere-volume (vSphere in-tree)

Non-vSphere volumes no longer block deletion. Conservative behavior: if VolumeAttachment lookup fails, treat as vSphere-backed and block.

Includes unit tests for volume type filtering and e2e test for NFS volume deletion scenario.

Summary by CodeRabbit

  • Bug Fixes

    • Machine deletion now proceeds when only non-vSphere volumes, such as NFS-backed storage, are attached.
    • Deletion remains safely blocked while vSphere-managed, unidentified, or unresolved volumes may still be attached.
    • Mixed volume attachments are handled correctly, preventing unnecessary deletion delays while protecting active vSphere storage.
  • Tests

    • Added coverage for NFS, vSphere, mixed, unknown, and other CSI volume scenarios.
    • Added end-to-end validation for deleting machines with non-vSphere volumes.

…olumes

The nodeHasVolumesAttached() check was volume-type-agnostic, blocking
machine deletion for any attached volume. This caused indefinite blocking
when non-VMDK volumes (NFS, iSCSI, etc.) were attached, since DaemonSet
pods with these volumes remain Running and never get evicted.

The VMDK data loss risk only applies to vSphere-backed volumes. This
change filters by VolumeAttachment.Spec.Attacher to only block for:
- csi.vsphere.vmware.com (vSphere CSI)
- kubernetes.io/vsphere-volume (vSphere in-tree)

Non-vSphere volumes no longer block deletion. Conservative behavior:
if VolumeAttachment lookup fails, treat as vSphere-backed and block.

Includes unit tests for volume type filtering and e2e test for NFS
volume deletion scenario.
@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 Aug 3, 2026
@openshift-ci

openshift-ci Bot commented Aug 3, 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

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 3, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jcpowermac: This pull request references Jira Issue OCPBUGS-101813, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

…olumes

The nodeHasVolumesAttached() check was volume-type-agnostic, blocking machine deletion for any attached volume. This caused indefinite blocking when non-VMDK volumes (NFS, iSCSI, etc.) were attached, since DaemonSet pods with these volumes remain Running and never get evicted.

The VMDK data loss risk only applies to vSphere-backed volumes. This change filters by VolumeAttachment.Spec.Attacher to only block for:

  • csi.vsphere.vmware.com (vSphere CSI)
  • kubernetes.io/vsphere-volume (vSphere in-tree)

Non-vSphere volumes no longer block deletion. Conservative behavior: if VolumeAttachment lookup fails, treat as vSphere-backed and block.

Includes unit tests for volume type filtering and e2e test for NFS volume deletion scenario.

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 commented Aug 3, 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 racheljpg 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

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 81ddd269-9fd9-4740-b9e2-6b8c064a57f9

📥 Commits

Reviewing files that changed from the base of the PR and between bd366a4 and 8eb49f2.

📒 Files selected for processing (3)
  • pkg/controller/vsphere/reconciler.go
  • pkg/controller/vsphere/reconciler_test.go
  • test/e2e/vsphere/machines.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/e2e/vsphere/machines.go
  • pkg/controller/vsphere/reconciler.go
  • pkg/controller/vsphere/reconciler_test.go

Walkthrough

Changes

The vSphere reconciler classifies attached volumes by VolumeAttachment.Spec.Attacher. vSphere volumes block deletion. Known non-vSphere volumes do not. Unit and end-to-end tests cover these paths.

vSphere volume-aware machine deletion

Layer / File(s) Summary
Classify attached volumes
pkg/controller/vsphere/reconciler.go
The reconciler looks up VolumeAttachment objects, correlates direct and hashed attachment names, and classifies vSphere, non-vSphere, and unknown attachers.
Validate deletion decisions
pkg/controller/vsphere/reconciler_test.go
Table-driven tests cover vSphere CSI, in-tree vSphere, non-vSphere, mixed, missing, empty, and unknown attachments.
Validate non-VMDK machine deletion
test/e2e/vsphere/machines.go, ocpbugs-101813.md
The end-to-end test mounts an NFS-backed PVC, deletes the machine, and verifies node recovery. The bug report documents the behavior and test scenarios.

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

Sequence Diagram(s)

sequenceDiagram
  participant Reconciler
  participant KubernetesAPI
  participant vCenter
  Reconciler->>KubernetesAPI: Look up VolumeAttachment objects
  KubernetesAPI-->>Reconciler: Return attachers or lookup results
  Reconciler->>Reconciler: Classify attached volumes
  Reconciler->>vCenter: Delete VM when no vSphere volume blocks deletion
  Reconciler-->>Reconciler: Requeue when a vSphere volume blocks deletion
Loading

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error New klog statements include machineName, nodeName, VolumeAttachment names, and volume names, which can expose internal hostnames and infrastructure/customer identifiers. Remove or sanitize node, machine, and volume identifiers from logs; log only counts, driver categories, and stable non-sensitive error codes.
Test Structure And Quality ⚠️ Warning Both tests fail quality requirements. Unit test (TestDeleteWithVolumeTypeFiltering) lacks assertion messages on 2 Expect calls. E2E test has 14+ Expect calls without meaningful messages and lacks c... Unit test: Add messages to g.Expect(err).NotTo(HaveOccurred()) and g.Expect(addDiskToVm(...)).To(Succeed()). E2E test: Add messages to all Expect(err).NotTo(HaveOccurred()) calls and wrap machine creation with defer cleanup to guarantee...
Ipv6 And Disconnected Network Test Compatibility ⚠️ Warning The e2e test at line 375 uses a hardcoded public registry image (registry.redhat.io/ubi9/ubi-minimal:v9.5). This requires external internet connectivity to pull images, which will fail in IPv6-only... Add [Skipped:Disconnected] tag to test name, or replace public registry image with cluster-internal registry/imagestream that works in disconnected environments.
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: restricting vSphere machine deletion blocking to VMDK-backed volumes.
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 All test names are static strings without dynamic content. Unit tests use descriptive static names, and e2e test titles contain no generated identifiers, timestamps, or variable node/namespace names.
Microshift Test Compatibility ✅ Passed New e2e test includes [apigroup:machine.openshift.io] tag, which automatically skips the test on MicroShift CI jobs that do not serve the machine.openshift.io API group.
Single Node Openshift (Sno) Test Compatibility ✅ Passed New e2e test does not make explicit multi-node assumptions per custom check criteria. Pod is pinned to single node; node scaling (add/delete 1) works on SNO topology. Has skip guards for missing ma...
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies vSphere machine deletion logic to filter volumes by storage driver type. No deployment manifests, pod specs, or scheduling constraints are added or modified. Changes are topology-agnostic.
Ote Binary Stdout Contract ✅ Passed No OTE Binary Stdout Contract violations detected. All code writes occur within test blocks (intercepted by Ginkgo framework) or function-level logging; no process-level stdout emissions found.
No-Weak-Crypto ✅ Passed The added diff contains no MD5, SHA1, DES, 3DES, RC4, Blowfish, ECB, custom crypto, or secret-token comparison; crypto/tls was pre-existing.
Container-Privileges ✅ Passed The added PodSpec contains no privileged, host namespace, SYS_ADMIN, allowPrivilegeEscalation, or root-user settings; the added-line scan found no privilege fields.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.12.2)

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.

@jcpowermac

Copy link
Copy Markdown
Contributor Author

/test ?

@jcpowermac

Copy link
Copy Markdown
Contributor Author

/test e2e-vsphere-ovn-techpreview-serial

@jcpowermac

Copy link
Copy Markdown
Contributor Author

/test unit

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

🤖 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 `@pkg/controller/vsphere/reconciler_test.go`:
- Around line 2598-2771: Extend the volumeTypeFilteringTestCases table to cover
nodeHasVolumesAttached conservative fallbacks: add a case with a node-attached
volume but no matching VolumeAttachment object, and a case with a matching
attachment whose Attacher is empty or unrecognized. Configure both cases to
expect deletion blocking with the existing attached-volumes requeue error, and
retain the established machine/node setup and reconcile assertions.

In `@pkg/controller/vsphere/reconciler.go`:
- Around line 581-587: Update the VolumeAttachment attacher classification
around the switch in the reconciler so only explicitly recognized safe
non-vSphere attachers remain in nonVSphereVolumes; route unknown or empty
Attacher values into unknownVolumes, alongside failed lookups. Ensure the
existing unknownVolumes handling and logging are exercised, preserving vSphere
attachers in vsphereVolumes.
- Around line 567-587: The VolumeAttachment lookup in the node volume
classification loop must use the production metadata name for CSI attachments
rather than treating AttachedVolume.Name as the object name. Update the logic
around apiReader.Get and the surrounding reconciliation method to derive the
csi-<sha256(volumeHandle+driver+nodeName)> name, or list and correlate
VolumeAttachment objects by node and attached volume, so non-vSphere CSI volumes
are classified by their real attacher. Update the related tests to use
production-style hashed VolumeAttachment names.

In `@test/e2e/vsphere/machines.go`:
- Around line 282-354: The test must attach an NFS volume to the created
machine’s node before deletion. Extend the flow around testNSName,
nfsStorageClassName, and the machine readiness check to create a PVC and
mounting Pod or DaemonSet using that storage class, ensure it schedules onto
machine.Name’s node, and wait for the corresponding VolumeAttachment or
node.Status.VolumesAttached entry before deleting the machine. Keep the existing
deletion and cluster-size assertions unchanged.
🪄 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: c530423b-96ea-445c-9067-22760792a36c

📥 Commits

Reviewing files that changed from the base of the PR and between aaa83f7 and 035aa63.

📒 Files selected for processing (4)
  • ocpbugs-101813.md
  • pkg/controller/vsphere/reconciler.go
  • pkg/controller/vsphere/reconciler_test.go
  • test/e2e/vsphere/machines.go

Comment thread pkg/controller/vsphere/reconciler_test.go
Comment thread pkg/controller/vsphere/reconciler.go
Comment thread pkg/controller/vsphere/reconciler.go
Comment thread test/e2e/vsphere/machines.go
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@jcpowermac: 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-vsphere-ovn-techpreview-serial 035aa63 link false /test e2e-vsphere-ovn-techpreview-serial

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-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 4, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@jcpowermac: This pull request references Jira Issue OCPBUGS-101813, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

…olumes

The nodeHasVolumesAttached() check was volume-type-agnostic, blocking machine deletion for any attached volume. This caused indefinite blocking when non-VMDK volumes (NFS, iSCSI, etc.) were attached, since DaemonSet pods with these volumes remain Running and never get evicted.

The VMDK data loss risk only applies to vSphere-backed volumes. This change filters by VolumeAttachment.Spec.Attacher to only block for:

  • csi.vsphere.vmware.com (vSphere CSI)
  • kubernetes.io/vsphere-volume (vSphere in-tree)

Non-vSphere volumes no longer block deletion. Conservative behavior: if VolumeAttachment lookup fails, treat as vSphere-backed and block.

Includes unit tests for volume type filtering and e2e test for NFS volume deletion scenario.

Summary by CodeRabbit

  • Bug Fixes

  • Machine deletion now proceeds when only non-vSphere volumes, such as NFS-backed storage, are attached.

  • Deletion remains safely blocked while vSphere-managed, unidentified, or unresolved volumes may still be attached.

  • Mixed volume attachments are handled correctly, preventing unnecessary deletion delays while protecting active vSphere storage.

  • Tests

  • Added coverage for NFS, vSphere, mixed, unknown, and other CSI volume scenarios.

  • Added end-to-end validation for deleting machines with non-vSphere volumes.

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 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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
pkg/controller/vsphere/reconciler_test.go (2)

2887-2889: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Use one deadline-bound context for simulator operations.

context.TODO() and context.Background() have no deadline. If AddDevice or reconciler.delete() stalls, this test can wait indefinitely. Create a context.WithTimeout context per subtest and pass it to both operations.

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

Also applies to: 2913-2918

🤖 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/controller/vsphere/reconciler_test.go` around lines 2887 - 2889, Create
one deadline-bound context with context.WithTimeout per subtest in the relevant
test flow, and defer its cancellation. Reuse that context for addDiskToVm and
the reconciler.delete operation, replacing context.TODO()/context.Background()
so both simulator operations terminate when the deadline expires.

Source: Path instructions


2880-2881: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Release simulator resources after each subtest.

Each table entry creates a simulator model and server. The subtest does not call srv.Close() or model.Remove(). Repeated cases can retain listeners and simulator resources until process exit.

Proposed fix
 model, sess, srv := initSimulator(t)
+t.Cleanup(func() {
+	srv.Close()
+	model.Remove()
+})
 simParams, err := getVcenterSimParams(srv, namespace)
🤖 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/controller/vsphere/reconciler_test.go` around lines 2880 - 2881, Update
the table-driven subtest around initSimulator to release each simulator’s
resources before the subtest exits: ensure srv.Close() and model.Remove() are
called for every entry, including when the subtest fails, using cleanup or
deferred teardown tied to the subtest lifecycle.
test/e2e/vsphere/machines.go (1)

293-299: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Select only attachers that the reconciler treats as non-vSphere.

This test treats openshift-storage.noobaa.io as an NFS provisioner. pkg/controller/vsphere/reconciler.go permits only nfs.csi.k8s.io and csi.nfs.io in its non-vSphere branch. The NooBaa attacher reaches the unknown branch and blocks deletion.

Remove openshift-storage.noobaa.io from this selection, or add the same attacher to the reconciler policy and its unit coverage.

🤖 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/machines.go` around lines 293 - 299, Update the storage
class selection in the test’s storageClasses loop to recognize only provisioners
permitted by the reconciler’s non-vSphere branch: nfs.csi.k8s.io and csi.nfs.io.
Remove openshift-storage.noobaa.io from the condition, unless instead you also
update the reconciler policy and its unit coverage consistently.
♻️ Duplicate comments (1)
pkg/controller/vsphere/reconciler_test.go (1)

2598-2605: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover the remaining vSphere attachment paths.

The table does not test VSphereInTreePluginName, although nodeHasVolumesAttached blocks this attacher.

The name-matched fixtures make the first Get succeed. The missing-attachment case only tests an empty list result. Add cases that force Get to return NotFound and List to return a matching attachment, and that force a lookup error. Assert the required deletion and blocking outcomes.

🤖 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/controller/vsphere/reconciler_test.go` around lines 2598 - 2605, Extend
the volumeTypeFilteringTestCases table and its test logic to cover
VSphereInTreePluginName, including name-matched fixtures where Get returns
NotFound, List returns a matching attachment, and lookup returns an error.
Assert that the NotFound/list paths produce the required deletion behavior and
that lookup errors preserve the expected blocking outcome, while keeping
existing attacher cases unchanged.
🤖 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/machines.go`:
- Around line 363-417: Reorder the flow so the Pod creation follows PVC creation
rather than waiting for ClaimBound first, allowing WaitForFirstConsumer
provisioning. Replace the generic node.Status.VolumesAttached length check with
waits that verify pvcName reaches ClaimBound and podName reaches Running on
nodeName; if validating reconciler correlation, additionally locate the PVC’s
VolumeAttachment and confirm its nodeName and expected attacher.
- Around line 372-407: Update the container image in the Pod created by the NFS
test setup around the pod creation call, replacing
registry.redhat.io/ubi8/ubi-minimal:latest with the repository’s configured or
cluster-provided test image, or a fixed digest. Keep the existing container
behavior unchanged while ensuring image resolution is deterministic and does not
depend on an unpinned external tag.

---

Outside diff comments:
In `@pkg/controller/vsphere/reconciler_test.go`:
- Around line 2887-2889: Create one deadline-bound context with
context.WithTimeout per subtest in the relevant test flow, and defer its
cancellation. Reuse that context for addDiskToVm and the reconciler.delete
operation, replacing context.TODO()/context.Background() so both simulator
operations terminate when the deadline expires.
- Around line 2880-2881: Update the table-driven subtest around initSimulator to
release each simulator’s resources before the subtest exits: ensure srv.Close()
and model.Remove() are called for every entry, including when the subtest fails,
using cleanup or deferred teardown tied to the subtest lifecycle.

In `@test/e2e/vsphere/machines.go`:
- Around line 293-299: Update the storage class selection in the test’s
storageClasses loop to recognize only provisioners permitted by the reconciler’s
non-vSphere branch: nfs.csi.k8s.io and csi.nfs.io. Remove
openshift-storage.noobaa.io from the condition, unless instead you also update
the reconciler policy and its unit coverage consistently.

---

Duplicate comments:
In `@pkg/controller/vsphere/reconciler_test.go`:
- Around line 2598-2605: Extend the volumeTypeFilteringTestCases table and its
test logic to cover VSphereInTreePluginName, including name-matched fixtures
where Get returns NotFound, List returns a matching attachment, and lookup
returns an error. Assert that the NotFound/list paths produce the required
deletion behavior and that lookup errors preserve the expected blocking outcome,
while keeping existing attacher cases unchanged.
🪄 Autofix

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: fc19e4b2-2cdd-432d-b0a9-6f58ccf03c43

📥 Commits

Reviewing files that changed from the base of the PR and between 035aa63 and eedede3.

📒 Files selected for processing (3)
  • pkg/controller/vsphere/reconciler.go
  • pkg/controller/vsphere/reconciler_test.go
  • test/e2e/vsphere/machines.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/controller/vsphere/reconciler.go

Comment thread test/e2e/vsphere/machines.go Outdated
Comment on lines +372 to +407
By("creating Pod that mounts the NFS volume on the target node")
podName := "nfs-test-pod-" + machineName
_, err = c.CoreV1().Pods(testNSName).Create(ctx, &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Namespace: testNSName,
},
Spec: corev1.PodSpec{
NodeName: nodeName,
Containers: []corev1.Container{
{
Name: "nfs-test",
Image: "registry.redhat.io/ubi8/ubi-minimal:latest",
Command: []string{
"sh", "-c", "while true; do sleep 3600; done",
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "nfs-volume",
MountPath: "/mnt/nfs",
},
},
},
},
Volumes: []corev1.Volume{
{
Name: "nfs-volume",
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: pvcName,
},
},
},
},
},
}, metav1.CreateOptions{})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

# First, confirm the exact content at the specified lines
sed -n '372,407p' test/e2e/vsphere/machines.go

Repository: openshift/machine-api-operator

Length of output: 1120


🏁 Script executed:

# Search for image-related constants or configuration in the test directory
rg "registry\.|ubi|image.*=" test/e2e/ -A 2 -B 2 | head -100

Repository: openshift/machine-api-operator

Length of output: 483


🏁 Script executed:

# Look for test image setup or fixtures
fd -e go test/e2e/ -type f -exec rg -l "Image:|testImage|imageURL" {} \;

Repository: openshift/machine-api-operator

Length of output: 401


🏁 Script executed:

# Search for any test configuration or setup that might define a default image
rg "testImage|TEST_IMAGE|ImageName" test/e2e/vsphere/ -A 2

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Search for how other e2e tests handle pod images
rg "Image:" test/e2e/ -B 2 -A 0 | grep -v "ubi-minimal"

Repository: openshift/machine-api-operator

Length of output: 258


🏁 Script executed:

# Search for test image constants or configuration files
rg -i "testimage|image.*constant|fixture" test/ --type go | head -20

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Look for any centralized image configuration in the test directory
find test -name "*.go" -exec rg "const.*Image|var.*Image" {} + | head -20

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Check for image pull or mirror configuration
rg "imagePull|registry|mirror" test/e2e/vsphere/machines.go -B 2 -A 2

Repository: openshift/machine-api-operator

Length of output: 338


🏁 Script executed:

# Look at the broader context of the test function to understand test setup
sed -n '340,380p' test/e2e/vsphere/machines.go

Repository: openshift/machine-api-operator

Length of output: 1696


🏁 Script executed:

# Search for any documentation about test image handling
find test -name "*.md" -o -name "README*" -o -name "*.txt" | xargs cat 2>/dev/null | grep -i image | head -20

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Look for test setup files or helpers that might configure images
rg "BeforeSuite|SetupTest|Setup" test/e2e/vsphere/machines.go -B 2 -A 5

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Check what the actual test function looks like to understand context
sed -n '300,340p' test/e2e/vsphere/machines.go

Repository: openshift/machine-api-operator

Length of output: 1779


🏁 Script executed:

# Search for any container image registry configuration in the codebase
rg -i "containerimage|image.registry" . --type go -l | head -10

Repository: openshift/machine-api-operator

Length of output: 723


🏁 Script executed:

# Look for how images are configured in CI/test environments
find . -name "Makefile" -o -name "*.sh" -o -name ".github" -type d | head -10

Repository: openshift/machine-api-operator

Length of output: 921


🏁 Script executed:

# Look at the root Makefile for test execution patterns
head -100 Makefile

Repository: openshift/machine-api-operator

Length of output: 3180


🏁 Script executed:

# Search for any test requirements or documentation
ls -la . | grep -i readme
cat README.md 2>/dev/null | head -50

Repository: openshift/machine-api-operator

Length of output: 2300


🏁 Script executed:

# Check if there are any image pull policies or test fixtures defined
rg "ImagePullPolicy|image.pull" test/e2e/vsphere/ -B 2 -A 2

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Look for any network or internet access restrictions in tests
rg -i "offline|network|internet|air.gap" test/e2e/ -l

Repository: openshift/machine-api-operator

Length of output: 281


🏁 Script executed:

# Check how the test is actually invoked - look for test files
ls -la test/e2e/vsphere/

Repository: openshift/machine-api-operator

Length of output: 600


🏁 Script executed:

# Check the e2e.sh script to understand test configuration
cat hack/e2e.sh

Repository: openshift/machine-api-operator

Length of output: 340


🏁 Script executed:

# Look for any test helper or util files that might configure images
cat test/e2e/vsphere/util.go

Repository: openshift/machine-api-operator

Length of output: 10717


🏁 Script executed:

# Search for any image configuration in setup or initialization
rg "registry.redhat.io|ubi8|ubi-minimal" . --type go -B 3 -A 1 | head -50

Repository: openshift/machine-api-operator

Length of output: 11956


🏁 Script executed:

# Verify if the coding guidelines referenced in the original comment actually exist
cat /dev/null  # Just confirming - let me check what guidelines were provided

Repository: openshift/machine-api-operator

Length of output: 168


🏁 Script executed:

# Check for any documentation about image pinning or test stability requirements
find . -name "*.md" -o -name "CONTRIBUTING*" | xargs grep -l "image\|pin\|digest" 2>/dev/null | head -5

Repository: openshift/machine-api-operator

Length of output: 364


🏁 Script executed:

# Look for other test files to see if there's a pattern for how images should be handled
rg "Image:" test/ -B 3 -A 1 --type go | grep -E "(Image:|^test/)" | head -30

Repository: openshift/machine-api-operator

Length of output: 465


Replace the mutable image tag with a pinned digest or configured test image.

The Pod uses registry.redhat.io/ubi8/ubi-minimal:latest, which has two issues: the :latest tag is mutable and may resolve to different image content on each test run, and the external registry dependency adds a network requirement to the test. Replace this with either a digest pin (e.g., registry.redhat.io/ubi8/ubi-minimal@sha256:...) or use a test image that the cluster provides or mirrors locally, ensuring deterministic and reliable test execution.

🤖 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/machines.go` around lines 372 - 407, Update the container
image in the Pod created by the NFS test setup around the pod creation call,
replacing registry.redhat.io/ubi8/ubi-minimal:latest with the repository’s
configured or cluster-provided test image, or a fixed digest. Keep the existing
container behavior unchanged while ensuring image resolution is deterministic
and does not depend on an unpinned external tag.

Source: Coding guidelines

@jcpowermac
jcpowermac force-pushed the ocpbugs-101813-volume-type-filtering branch from eedede3 to bd366a4 Compare August 4, 2026 12:27

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

🧹 Nitpick comments (1)
pkg/controller/vsphere/reconciler_test.go (1)

2455-2597: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated test helpers.

vCenterSimConfig, getVcenterSimParams, getMachineWithStatus, getNodeWithConditions, and addDiskToVm are copies of the closures in TestDelete (lines 1935-2059 and 2223-2252). The two copies differ only in instanceUUID. Two copies will drift when the simulator setup changes.

Move these to package-level test helpers in this file, parameterize instanceUUID and nodeName, and call them from both tests.

🤖 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/controller/vsphere/reconciler_test.go` around lines 2455 - 2597, Extract
vCenterSimConfig and the helpers getVcenterSimParams, getMachineWithStatus,
getNodeWithConditions, and addDiskToVm from TestDeleteWithVolumeTypeFiltering
and TestDelete into package-level test helpers. Add instanceUUID and nodeName
parameters where needed, preserving each test’s current values and behavior,
then update both tests to call the shared helpers and remove their duplicated
local closures.
🤖 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 `@pkg/controller/vsphere/reconciler_test.go`:
- Around line 2810-2837: Register the fake client's VolumeAttachment field index
for spec.nodeName in the test setup used by the reconciler cases, including the
index key expected by the fallback List in the missing-attachment scenario.
Ensure the existing test reaches the va == nil path instead of failing because
the field selector index is unavailable.

---

Nitpick comments:
In `@pkg/controller/vsphere/reconciler_test.go`:
- Around line 2455-2597: Extract vCenterSimConfig and the helpers
getVcenterSimParams, getMachineWithStatus, getNodeWithConditions, and
addDiskToVm from TestDeleteWithVolumeTypeFiltering and TestDelete into
package-level test helpers. Add instanceUUID and nodeName parameters where
needed, preserving each test’s current values and behavior, then update both
tests to call the shared helpers and remove their duplicated local closures.
🪄 Autofix

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: ad47fa12-ce18-438c-b167-f6e793884628

📥 Commits

Reviewing files that changed from the base of the PR and between eedede3 and bd366a4.

📒 Files selected for processing (3)
  • pkg/controller/vsphere/reconciler.go
  • pkg/controller/vsphere/reconciler_test.go
  • test/e2e/vsphere/machines.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/e2e/vsphere/machines.go
  • pkg/controller/vsphere/reconciler.go

Comment thread pkg/controller/vsphere/reconciler_test.go
- Whitelist known safe non-vSphere CSI attachers instead of blanket default
- Route empty/unrecognized attachers to unknownVolumes, blocking deletion
- Add VolumeAttachment fallback correlation via node-list for hashed CSI names
- Add tests for missing VA, empty attacher, and unknown attacher cases
- Update e2e test to actually attach NFS volume before machine deletion
@jcpowermac
jcpowermac force-pushed the ocpbugs-101813-volume-type-filtering branch from bd366a4 to 8eb49f2 Compare August 4, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants