Repository navigation
Commit 60357eb
authored
fix(csi): route RWX Block volumes to upstream hotplug detach (#2658)
## What this PR does
Fixes routing in `WrappedControllerService` so RWX **Block** volumes
(KubeVirt live-migration disks) are no longer treated as NFS during
unpublish and expand.
### Root cause
`ControllerUnpublishVolume` selected the NFS cleanup branch based on
`hasRWXAccessMode(pvc)` alone. RWX Block matched and went down the NFS
path — which just deletes a `CiliumNetworkPolicy`. For a block volume
that CNP does not exist, so `removeCNPOwnerReference` returns
successfully without doing anything, and the function reports success
without ever calling upstream's hotplug detach. The DataVolume entry
stays in `VM.spec.template.spec.volumes` permanently. When the same PVC
later attaches to a different VM, linstor-csi's anti-split-brain check
sees pods from two different VMs referencing the same RWX block PVC and
blocks the attach with:
```
RWX block volume <ns>/<pvc> is being used by pods from different VMs (<vm-a> and <vm-b>);
this is not supported - RWX block volumes with allow-two-primaries are only for live migration of a single VM
```
`ControllerPublishVolume` was unaffected because it routes on the
explicit `nfsVolumeKey` from `VolumeContext`.
`ControllerUnpublishVolume` does not receive `VolumeContext` and has to
infer from the PVC, and the previous inference was incomplete.
### Fix
`isNFSVolume(pvc)` now requires `ReadWriteMany` access mode **and**
`VolumeMode == Filesystem` (always set by our NFS `CreateVolume` path).
RWX Block correctly delegates to upstream `ControllerUnpublishVolume`,
which removes the entry from VM spec via `RemoveVolumeFromVM`. The same
predicate replaces the previous access-mode check in
`ControllerExpandVolume`, which was also clearing
`NodeExpansionRequired` for RWX Block — block volumes still need in-VM
disk expansion.
Fixes #2634.
### Release note
```release-note
fix(csi): route RWX Block volumes in kubevirt-csi-driver to upstream hotplug detach so VM spec entries are cleaned up on unpublish
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* More accurate detection of network-attached (NFS) vs block volumes,
preventing incorrect cleanup of block volumes.
* NFS volumes continue to receive special cleanup; non-NFS volumes now
follow upstream cleanup paths.
* **Refactor**
* Node-side expansion logic refined to base decisions on improved NFS
classification (RWX + filesystem), reducing expansion errors.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/cozystack/cozystack/pull/2658?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 file changed
Lines changed: 20 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
366 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
367 | 371 | | |
368 | 372 | | |
369 | 373 | | |
370 | | - | |
371 | 374 | | |
372 | 375 | | |
373 | 376 | | |
| |||
376 | 379 | | |
377 | 380 | | |
378 | 381 | | |
379 | | - | |
| 382 | + | |
380 | 383 | | |
381 | 384 | | |
382 | 385 | | |
| |||
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
407 | | - | |
| 410 | + | |
| 411 | + | |
408 | 412 | | |
409 | 413 | | |
410 | 414 | | |
411 | | - | |
| 415 | + | |
412 | 416 | | |
413 | 417 | | |
414 | 418 | | |
| |||
544 | 548 | | |
545 | 549 | | |
546 | 550 | | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
547 | 561 | | |
548 | 562 | | |
549 | 563 | | |
| |||
0 commit comments