Repository navigation
Allow growing a running KVM VM's ROOT volume through a new disk offering - #14602
Open
bhouse-nexthop wants to merge 1 commit into
Open
bhouse-nexthop wants to merge 1 commit into
bhouse-nexthop wants to merge 1 commit into
Conversation
A size-only resizeVolume of a ROOT volume already works on a running KVM
VM: orchestrateResizeVolume checks that the host is Up and Enabled, and
the agent grows the disk in place with virsh blockresize.
Growing the same volume by giving it a larger disk offering is refused,
through resizeVolume with diskofferingid, through changeOfferingForVolume,
and so through scaleVirtualMachine when
allow.diskoffering.change.during.scale.vm is on:
Cannot resize ROOT volume [...] when VM is not on Stopped State
checkIfVolumeIsRootAndVmIsRunning, which the size-only path does not
call, refuses any size change of a ROOT volume unless the VM is Stopped,
on every hypervisor. Where the ROOT volume's offering fixes its size, the
size-only path is refused too, so stopping the VM was the only way to
grow its root disk.
Let the check through when the volume belongs to a Running KVM user VM
and the new size is larger than the current one. Shrinking, other
hypervisors, system VMs and other VM states are refused as before. The
resize then follows the same path as a size-only resize of a running VM.
Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14602 +/- ##
============================================
- Coverage 18.32% 18.32% -0.01%
- Complexity 16644 16650 +6
============================================
Files 5939 5939
Lines 537768 537774 +6
Branches 65929 65931 +2
============================================
+ Hits 98551 98552 +1
- Misses 428008 428013 +5
Partials 11209 11209
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:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On KVM, growing a running VM's ROOT volume by giving it a larger disk offering was refused with "Cannot resize ROOT volume [...] when VM is not on Stopped State", although a size-only
resizeVolumegrows the same volume in place.Fixes #14601
Why it breaks
resizeVolume id=<root> size=<n>reachesorchestrateResizeVolume, which handles a running KVM VM (it checks that the host is Up and Enabled). The agent grows the disk withvirsh blockresize(LibvirtResizeVolumeCommandWrapper,resizevolume.sh).resizeVolumewithdiskofferingidandchangeOfferingForVolumeboth callcheckIfVolumeIsRootAndVmIsRunning. So doesscaleVirtualMachineof a running VM whenallow.diskoffering.change.during.scale.vmis on, throughchangeOfferingForVolume. That refuses any size change of a ROOT volume unless the VM is Stopped, on every hypervisor. It was added in Allow to configure root disk size via Service Offering (diskoffering of type Service). #4341, when ROOT volumes were first allowed to change disk offering, and was never relaxed for KVM.isNotPossibleToResize), so the only remaining way to grow the root disk was to stop the VM.How it is fixed
checkIfVolumeIsRootAndVmIsRunningnow lets the change through when all of these hold:orchestrateResizeVolumeonly looks up the running VM and its host for user VMs);Everything else is refused as before:
Nothing below the check changes. The resize then takes the same route as a size-only resize of a running VM: the same job queue,
orchestrateResizeVolumeand its host checks, and the same agent command. The existing checks that apply to every running KVM VM still apply, for example a managed storage pool still refuses a resize while the VM is running (validateVolumeResizeWithSize).Not in scope / existing behaviour now reachable for ROOT
allow.diskoffering.change.during.scale.vmon, scaling a running KVM VM to an offering with a larger root disk now grows the root disk instead of failing. The setting's description already says it covers running VMs. The root disk is changed before CPU and memory are reconfigured, which is the existing order inupgradeRunningVirtualMachine.iotuneuntil the VM is restarted. This is how a data disk's offering change already behaves.Growing the partition and filesystem inside the guest (
growpart,resize2fs) is up to the guest, as it already is for a size-only resize. cloud-init only does it at boot.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
VolumeApiServiceImplTestforcheckIfVolumeIsRootAndVmIsRunning:VolumeApiServiceImplTestclass passes (152 tests), with checkstyle, on the4.22branch.resizeVolumeof a running KVM VM already takes. That was confirmed by reading the code, not by running it.How did you try to break this feature and the system with this change?
resizeVolumeInternal,validateVolumeReadyStateAndHypervisorChecks) are unchanged.validateVolumeResizeWithSize, which both paths call.migrateVolumeexactly as it does for a data disk of a running VM today, with the same restrictions.