Feature #4393

Resize operation for VM disks

Added by Tino Vázquez over 5 years ago. Updated almost 4 years ago.

Status:ClosedStart date:04/06/2016
Priority:HighDue date:
Assignee:Vlastimil Holer% Done:

0%

Category:Core & System
Target version:Release 5.4
Resolution:fixed Pull request:

Description

In poweroff and/or running states. This should be available for KVM and vCenter

resize_disk2.patch Magnifier (1.68 KB) Anton Todorov, 06/07/2017 08:49 PM


Related issues

Related to Feature #4867: Ability to add disks to existing vm's Closed 10/12/2016
Duplicated by Backlog #4596: Resize disk while VM is running Closed 06/23/2016
Duplicated by Request #4755: Disk resize at runtime Closed 08/31/2016

Associated revisions

Revision 256b1dc3
Added by Javi Fontan over 4 years ago

F #4393: add resize_disk action to one_vmm_exec

Revision bbb3466b
Added by Javi Fontan over 4 years ago

F #4393: move get_disk_information to library

Revision 3ebdc8d8
Added by Javi Fontan over 4 years ago

F #4393: add vmm/kvm/resize_disk

Revision 53413e0c
Added by Javi Fontan over 4 years ago

F #4393: add tm/{qcow2/shared/ssh}/resize

Revision 3f3e1379
Added by Javi Fontan over 4 years ago

F #4393: add disk-resize to oca and cli

Revision ad4b967c
Added by Javi Fontan over 4 years ago

F #4393: bug in get_disk_information

Revision b6e62cc1
Added by Javi Fontan over 4 years ago

F #4393: add resize placeholders for tm and vmm

Revision 4715e76c
Added by Javi Fontan over 4 years ago

F #4393: tm/ceph/resize

Revision 398edc7b
Added by Javi Fontan over 4 years ago

F #4393: send resize notification failure through action info

Revision b3b94943
Added by Javi Fontan over 4 years ago

F #4393: change notification failure message

Revision bc456542
Added by Juan Jose Montiel Cano over 4 years ago

F #4393: Add new resize dialog, remove labels for disk actions. Include
better handling of units and cost for disks

Revision 9297321d
Added by Ruben S. Montero over 4 years ago

F #4393: New VirtualMachineDisk interface to abstract all disk
management logic. Adapted classes to new interface and re-allocated some
functions. Work on disk resize operations.

Revision 71e7b3dc
Added by Ruben S. Montero over 4 years ago

F #4393: Move authorize disk to VirtualMachineDisk class

Revision 178489ef
Added by Ruben S. Montero over 4 years ago

F #4393: Moved Saveas implementation to VirtualMachineDiks. Fix bugs

Revision c1c3d047
Added by Ruben S. Montero over 4 years ago

F #4393: More work on resize

Revision 6f3066dd
Added by Ruben S. Montero over 4 years ago

F #4393: Add resize API calls. Fix disk for SELF tm_mad drivers quotas.

Revision 43df8151
Added by Ruben S. Montero over 4 years ago

F #4393: Added resize operation for running VMs

Revision 3e9e0e88
Added by Ruben S. Montero over 4 years ago

F #4393: JAVA OCA for diskResize

Revision 04d01697
Added by Ruben S. Montero over 4 years ago

F #4393: Add Resize states to Sunstone and OneGate

Revision 4f8d5ddc
Added by Javi Fontan over 4 years ago

F #4393: add resize_disk action to one_vmm_exec

Revision 2d8a1cec
Added by Javi Fontan over 4 years ago

F #4393: move get_disk_information to library

Revision 84df4af9
Added by Javi Fontan over 4 years ago

F #4393: add vmm/kvm/resize_disk

Revision 98632bac
Added by Javi Fontan over 4 years ago

F #4393: add tm/{qcow2/shared/ssh}/resize

Revision 0fa74d9a
Added by Javi Fontan over 4 years ago

F #4393: add disk-resize to oca and cli

Revision 7aced06a
Added by Javi Fontan over 4 years ago

F #4393: bug in get_disk_information

Revision 9413388e
Added by Javi Fontan over 4 years ago

F #4393: add resize placeholders for tm and vmm

Revision 65b7ace3
Added by Javi Fontan over 4 years ago

F #4393: tm/ceph/resize

Revision 65ee6826
Added by Javi Fontan over 4 years ago

F #4393: send resize notification failure through action info

Revision 167a163c
Added by Javi Fontan over 4 years ago

F #4393: change notification failure message

Revision bbf4d6a8
Added by Juan Jose Montiel Cano over 4 years ago

F #4393: Add new resize dialog, remove labels for disk actions. Include
better handling of units and cost for disks

Revision 517f87e0
Added by Ruben S. Montero over 4 years ago

F #4393: New VirtualMachineDisk interface to abstract all disk
management logic. Adapted classes to new interface and re-allocated some
functions. Work on disk resize operations.

Revision 0458a27d
Added by Ruben S. Montero over 4 years ago

F #4393: Move authorize disk to VirtualMachineDisk class

Revision 022ff676
Added by Ruben S. Montero over 4 years ago

F #4393: Moved Saveas implementation to VirtualMachineDiks. Fix bugs

Revision d3ac94c1
Added by Ruben S. Montero over 4 years ago

F #4393: More work on resize

Revision a15474a2
Added by Ruben S. Montero over 4 years ago

F #4393: Add resize API calls. Fix disk for SELF tm_mad drivers quotas.

Revision 91aef54f
Added by Ruben S. Montero over 4 years ago

F #4393: Added resize operation for running VMs

Revision 0225e609
Added by Ruben S. Montero over 4 years ago

F #4393: JAVA OCA for diskResize

Revision 5d1412e4
Added by Ruben S. Montero over 4 years ago

F #4393: Add Resize states to Sunstone and OneGate

Revision 27f63ead
Added by Ruben S. Montero over 4 years ago

F #4393: Fix error in updating quotas on resize failure

Revision 33568bcb
Added by Ruben S. Montero over 4 years ago

F #4393: Add missing method for resize action in Dummy driver

History

#1 Updated by Ruben S. Montero almost 5 years ago

  • Duplicated by Backlog #4596: Resize disk while VM is running added

#2 Updated by Ruben S. Montero almost 5 years ago

#3 Updated by Ruben S. Montero almost 5 years ago

  • Description updated (diff)

#4 Updated by Ruben S. Montero almost 5 years ago

  • Tracker changed from Backlog to Feature
  • Priority changed from Normal to High
  • Target version set to Release 5.4

#5 Updated by Carlos Cesario almost 5 years ago

Hello all,

I'm not a Ruby programmer, but I think that this piece of this code can help in this task.

https://github.com/bpaquet/rvc-ext/blob/master/modules/disk.rb#L7-L17
and
https://github.com/Identified/rbvsphere/blob/master/lib/rbvsphere/vm/configure.rb#L26-L34

-Carlos

#6 Updated by Ruben S. Montero over 4 years ago

  • Related to Feature #4867: Ability to add disks to existing vm's added

#7 Updated by Javi Fontan over 4 years ago

  • Assignee set to Javi Fontan

#8 Updated by John Noss over 4 years ago

This looks great! Will this also provide the ability to resize persistent images? (Will this make it possible to resize images that are not attached to vms, such as via Sunstone -> storage -> images or via the oneimage command?)

#10 Updated by John Noss about 4 years ago

John Noss wrote:

This looks great! Will this also provide the ability to resize persistent images? (Will this make it possible to resize images that are not attached to vms, such as via Sunstone -> storage -> images or via the oneimage command?)

Just tested this in the 5.4 beta (5.3.80) from the CLI (onevm disk-resize) and it works for non-persistent disks, but not for persistent disks. I added a fix to the ceph tm_mad to allow it to work for persistent disks too, see https://github.com/OpenNebula/one/pull/330 - can that be included in this for 5.4?

#11 Updated by Anton Todorov about 4 years ago

Hi John Noss,

Which version of libvirt and qemu-kvm you are using?

On libvirt 2.0.0/qemu-kvm 2.6.0 the VM is not notified for the disk size change and there is no error raised.

I am preparing a pull request to propose the use of the native libvirt interface to notify the VMs which is working on my setups. Butt it'll need extended testing on the different OS-es

BR,
Anton Todorov

#12 Updated by Anton Todorov about 4 years ago

Hi,

Actually the disk resize is working! Probably I've messed the hosts sync earlier today.

Anyway, here is the patch that uses 'virsh blockresize' instead of proxy to qemu-monitor-command. But not sure will it work on all OS-es though.


And an additional question - where to find the disk_resize interface in sunstone?

BR,
Anton

#13 Updated by Anton Todorov about 4 years ago

Hi,

There is one more bug but I am exploiting it as a feature so I kindly ask the resolution to have the option to use it.

There is a block in the use of disk-resize when there are disk snapshots.
For qcow2 it is mandatory but it is not an issue for storpool and most probably for other SDS too.
Beside that As there is no option to flatten/delete the last(active) snapshot the disk-resize is blocked for such disks.
Actually this sounds as separate bug?

That said, here is the actual bug I have in mind whe I've started writing the report:

I believe it is a bug that there is not blocking of disk-resize when there are VM snapshots too.

The problem is that I use the feature that uses the VM snapshot interface to do atomic disk snapshots(backups) on all VM disks at once by hooking the VM snapshot_* scripts to local ones (in the VMM_MAD configuration the '-l' argument) . And if you fix the bug by just blocking the disk-resize it will break this "feature" also.

I've not dig in the internals so my blind proposal for resolution is to add an argument to the TM_MAD definition for the given datastore to mark that the given TM_MAD is capable of handling the snapshots case.

Best Regards,
Anton Todorov

#14 Updated by Javi Fontan about 4 years ago

  • Assignee changed from Javi Fontan to Vlastimil Holer

#15 Updated by Javi Fontan about 4 years ago

John, your PR seems good. We will test it further for inclusion.

Anton:

  • About virsh blockresize: We are using qemu-monitor-command as we support some old versions of libvirt (Ubuntu 14.04).
  • About resize in Sunstone: There was a misunderstanding and the resize button is only enabled when the VM is in POWEROFF state. We are correcting that. Thanks for the heads up!
  • About the bug with snapshots: I don't fully understand the problem here. Maybe as you say it's a separate bug. Are you saying that after a resize you can not take snapshots of a VM?

There's also a bug in Sunstone that enables resize button for context disk that should be taken care.

I'm handing over the issue to Vlastimil Holer but I'll check it if needed.

#16 Updated by Vlastimil Holer almost 4 years ago

Ceph disks ... OK

The PR https://github.com/OpenNebula/one/pull/330 fixes the resizing of Ceph persistent disks, checked both disk types are working fine.

QCOW2

QCOW2 resize is correctly blocked by SUnstone/core if there are disk snapshot(s) present. But, if there are VM snapshots, the resize operation fails after a try. Maybe this is what Anton meant.

#17 Updated by Anton Todorov almost 4 years ago

Hi,

I'll try to clarify. There are most-probably different issues though:
1. even with ALLOW_ORPHANS="yes" in TM_MAD conf it is not possible to delete any disk snapshot
1.1 Sunstone don't allow deleting "current" snapshot with reason "[one.vm.disksnapshotdelete] Cannot delete the active snapshot"
1.2 Sunstone don't allow deleting "parent" snapshot with reason "[one.vm.disksnapshotdelete] Cannot delete snapshot with children"
1.3 it is not allowed to resize a disk if it has snapshots with reason "[one.vm.diskresize] Cannot resize a disk with snapshots"

(1.4 [new feture?] there is no option to do (atomic)snapshots on all VM disks at once in a single transaction)

All of the above constraints are not issue in StorPool. The snapshots in StorPool are exactly how the snapshot tree is drawn. And the active disk volume is the final leaf to a snapshot then. Each snapshot keeps only the changes against its parent. When a snapshot is deleted its changes are merged to its leaf(s) - either snapshot or the active volume. I'll try to explain with a simple drawing

a VM has one disk named DISK_0, when you do a snapshot it will have

SNAPSHOT_A
     \
      DISK_0

When you take a second snapshot you'll have

SNAPSHOT_A
     \
      SNAPSHOT_B
           \
            DISK_0

When you delete SNAPSHOT_A the shared data is copied to ites leaf.. in this case SNAPSHOT_B
When SNAPSHOT_B is deleted the shared data is copied back to its leaf - DISK_0

The only thing I can think of is that when a disk snapshot is created the actual disk size should be saved as an attribute to the snapshot and when a snapshot is restored - to alter the value in the VM tample with the value saved in the snapshot.
For example if we have a disk with size 10GB, take a snapshot and then resize the disk to 15 GB. When you revert the disk to the snapshot the resulting disk size will be reverted back to 10GB.

I am almost sure same is with CEPH too.

Regarding the VM snapshots.
When managed by libvirt they are locked to the current KVM host and for qcow2 images only. OpenNebula correctly delete the VM snapshots on migrate with KEEP_SNAPSHOTS=no in VMM_MAD. StorPool has no integration with libvirt so the VM snapshot interface is re-purposed to do (1.4 from above) - atomic snapshots on all disks with a single transaction. I achieve this by defining custom local snapshot scripts and setting KEEP_SNAPSHOTS=yes in the VMM_MAD configuration vector for KVM. Again the VM disk resize is in not limited in any way. The only issue is again the disk sizes in the internal VM_TEMPLATE for the cases when there are disk resizes involved after a snapshot is taken. Currently I am stopping oned and altering the database. An API interface to alter only the value would be greatly appreciate :)

There are some more features I am working on:
+ option to limit the number of snapshots per VM (disk and/or "modified" VM snapshots). Configurable per VM or a global attribute in the SYSTEM datastore template.
+ option to export a VM disk from given VM snapshot as a new image - there is a customer with this feature request(to fight ransomware somehow...)

As I am awful in the big explanations you are welcome to ask any questions to clarify :)

Best Regards,
Anton Todorov

#18 Updated by Vlastimil Holer almost 4 years ago

Hi Anton,

Anton Todorov wrote:

I'll try to clarify. There are most-probably different issues though:
1. even with ALLOW_ORPHANS="yes" in TM_MAD conf it is not possible to delete any disk snapshot
1.1 Sunstone don't allow deleting "current" snapshot with reason "[one.vm.disksnapshotdelete] Cannot delete the active snapshot"
1.2 Sunstone don't allow deleting "parent" snapshot with reason "[one.vm.disksnapshotdelete] Cannot delete snapshot with children"
(1.4 [new feture?] there is no option to do (atomic)snapshots on all VM disks at once in a single transaction)

I have made a separate feature request for these points
https://dev.opennebula.org/issues/5223
as they aren't much related to the core resize feature. Please, subscribe to the ticket to keep updated.

1.3 it is not allowed to resize a disk if it has snapshots with reason "[one.vm.diskresize] Cannot resize a disk with snapshots"

Yes, this is a known issue I have mentioned above.

I'm going to close this issue now, as the intended resize functionality targeting the release 5.4 is working. We will try to improve the resize and snapshots management in the next release.

Best regards,
Vlastimil Holer

#19 Updated by Vlastimil Holer almost 4 years ago

  • Status changed from Pending to Closed
  • Resolution set to fixed

Also available in: Atom PDF