Repository navigation
Refuse to resize the volume of a running system VM - #14647
bhouse-nexthop wants to merge 2 commits into
Conversation
A size-only resizeVolume of a running system VM's volume, such as a virtual router's ROOT, was accepted. orchestrateResizeVolume only looks the VM up as a user VM, so for a system VM the resize was sent with no instance name and no host. The storage and the database got the new size, but the hypervisor was never told and the running guest kept the old size until its next start. The XenServer and KVM host checks in the same method were skipped for the same reason. The resize validation now refuses to change the size of a volume attached to a system VM that is not Stopped. A stopped system VM's volume can still be resized. A ROOT resize through a new disk offering was already refused unless the VM was stopped. Fixes apache#14645 Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14647 +/- ##
============================================
- Coverage 18.32% 18.32% -0.01%
- Complexity 16644 16653 +9
============================================
Files 5939 5939
Lines 537768 537796 +28
Branches 65929 65933 +4
============================================
+ Hits 98551 98553 +2
- Misses 428008 428025 +17
- Partials 11209 11218 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Test report: resizing a virtual router's ROOT volumeSummary: a size-only Environment
Steps and results
Refusal message: Before this PR, the same call on a running router succeeded and grew the RBD image, while the router's disk kept its old size until it restarted. The resized router was never started again. It was destroyed with its network at the end of the test. Result: pass. Not covered
|
…pedForResize The check requires the system VM to be Stopped, not merely not Running, so name it after what it enforces. Signed-off-by: Brad House <bhouse@nexthop.ai>
Description
A size-only
resizeVolumeof a running system VM's volume, for example a virtual router's ROOT, was accepted. The storage and the database got the new size, but the running VM was never told, so the guest kept the old size until it next started. This PR refuses that resize unless the system VM is Stopped.Fixes #14645
Why it happens
orchestrateResizeVolumelooks the VM up only with_userVmDao.findById(). For a system VM that is null, so:noneand no host. On KVM the image is grown, butvirsh blockresizeis never run for the running domain;A ROOT resize through a new disk offering, in
resizeVolumeorchangeOfferingForVolume, is already refused unless the VM is Stopped (checkIfVolumeIsRootAndVmIsRunning). The size-onlyresizeVolumepath had no such check.Fix
validateVolumeResizeWithSize, which bothresizeVolumeandchangeOfferingForVolumecall before any size change, now refuses one more case. If the volume is attached to a system VM (VirtualMachine.Type.isUsedBySystem()) that is not Stopped, the call fails with:I chose to refuse rather than do the resize live. A live resize would need
orchestrateResizeVolumeto handle system VMs on every hypervisor, through the VM work queue and the host checks, and that needs testing on each one. Refusing matches how other volume operations treat system VMs: snapshots of their volumes are refused, and attach and detach accept only user VMs.This touches a different part of
VolumeApiServiceImplfrom #14602, and the two merge cleanly.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
The bug was seen on a KVM + Ceph RBD lab while testing #14602. A size-only
resizeVolume size=20on a running router's ROOT succeeded.rbd infoand the API showed 20 GiB, butvirsh domblkinfostill showed the old size until the router restarted. The fix itself is covered by unit tests; it has not been run on the lab yet.New tests in
VolumeApiServiceImplTest:validateSystemVmIsStoppedForResizeTestNotStoppedSystemVms: a router, console proxy, secondary storage VM and internal LB VM, each in Running, Starting, Stopping and Migrating, are all refused.validateSystemVmIsStoppedForResizeTestStoppedRouter,...TestRunningUserVmand...TestDetachedVolume: allowed. A detached volume needs no VM lookup.resizeVolumeSizeOnlyOnRunningRouterIsRefused: a size-only grow throughresizeVolumeon a running router's volume is refused, andVolumeService.resizeis never called. Without the new check, this request gets past validation.VolumeApiServiceImplTestpasses (150 tests). Checkstyle is clean forserver.How did you try to break this feature and the system with this change?
resizeVolume/changeDiskOfferingForVolumeInternalthat could resize a system VM's volume. There are two, Shared FileSystem and CKS, and both work on user VMs.isUsedBySystem(), so user, CKS and Shared FileSystem VMs (allType.User) are unaffected.