Backlog #1727

Patch for one.image.resize to resize image

Added by Simon Boulet about 6 years ago. Updated about 3 years ago.

Status:ClosedStart date:01/14/2013
Priority:HighDue date:
Assignee:-% Done:

0%

Category:Core & System
Target version:-

Description

This patch (against 3.8.1) adds a one.image.resize call to resize image.

The call takes 2 parameters: The image ID and the new size.

- It works for image that are in READY state (with some more work, it could be extended to USED state to allow non-persistent sources to be resized, and USED_PERS to allow online resizing).
- It requires the MANAGE IMAGE permission on an image to issue a resize action.
- It checks the image owner quota before accepting the resize.
- It sets the image in LOCKED state and calls a new datastore driver action, RESIZE.
- If the driver returns SUCCESS, it sets the image back to READY state, otherwise the image is set to ERROR.

This patch doesn't implement the RESIZE action in any of the datastore drivers shipped with OpenNebula. It only implements the resize at the OpenNebula Core level. The datastore drivers needs to be updated to handle the RESIZE action.

Beware that issuing a one.image.resize call to a datastore that wasn't updated to support the RESIZE action will leave the image in LOCKED (or ERROR) state.

Feedbacks are more than welcome!

Simon

image-resize.patch Magnifier (15.4 KB) Simon Boulet, 01/14/2013 11:48 PM

z-image-resize-used-pers.patch Magnifier (1.37 KB) Simon Boulet, 01/15/2013 10:44 PM

image-resize-4.2.patch Magnifier - Rebase against 4.2 (15.4 KB) Simon Boulet, 07/30/2013 06:01 AM

resize.image.rb.diff Magnifier (1.14 KB) Vladislav Gorbunov, 12/11/2013 02:15 AM

resize.oneimage.diff Magnifier (499 Bytes) Vladislav Gorbunov, 12/11/2013 02:15 AM


Related issues

Related to Request #1705: Resizable images Closed 12/27/2012
Related to Feature #1768: CloudInit and Instance Data, or replacing the current con... Closed 02/15/2013
Related to Feature #179: Ability to expand disk source on physical host Closed 12/03/2009
Related to Request #3044: Support resizing disk size Closed 07/15/2014
Related to Bug #4073: Docs still mention VOLATILE_DISK instead of SYSTEM_DISK_SIZE Closed 10/20/2015

Associated revisions

Revision edd210a8
Added by Carlos Martín over 3 years ago

Feature #1727: VM::set_auth_request adds size to each disk

Revision 2c2fa830
Added by Carlos Martín over 3 years ago

Feature #1727: VM volatile quota adds each disk size

Revision eca7640d
Added by Carlos Martín over 3 years ago

Feature #1727: Image::disk_attribute adds ORIGINAL_SIZE

Revision 66b83c0f
Added by Javi Fontan over 3 years ago

feature #1727: add clone resize to ssh, shared and qcow2

Revision 6e3e25ff
Added by Carlos Martín over 3 years ago

Feature #1727: Rename VOLATILE_SIZE quota to SYSTEM_DISK_SIZE

Revision 0a42146d
Added by Carlos Martín over 3 years ago

Feature #1727: New option --extend for onetemplate show

Revision 2f008932
Added by Carlos Martín over 3 years ago

Feature #1727: Do not allow disk resize for persistent images, and for a smaller size

Revision fc3de05f
Added by Carlos Martín over 3 years ago

Feature #1727: Fix system_disk quotas

Add DS disk attributes; add disk-snapshots to total

Revision 14c2f2a1
Added by Carlos Martín over 3 years ago

Feature #1727: Disk snapshot actions add/del from system disk quotas

Revision 098060ef
Added by Carlos Martín over 3 years ago

Feature #1727: Fix bug, extra semicolon

Revision b2334879
Added by Carlos Martín over 3 years ago

Feature #1727: Make snapshot size a long long, to be the same as image size

Revision 4fc84d98
Added by Carlos Martín over 3 years ago

Feature #1727: Update fsck to calculate SYSTEM_DISK quota

Revision 884ca29d
Added by Carlos Martín over 3 years ago

Feature #1727: New SYSTEM_DISK quota in onedb upgrade

Revision 42063afc
Added by Carlos Martín over 3 years ago

Feature #1727: Small code style change

Revision 7e127b1f
Added by Carlos Martín over 3 years ago

Feature #1727: Disk attach now adds to the SYSTEM_DISK quota

Revision 6278fd7e
Added by Anton Todorov over 3 years ago

feature #1727: fix bug setting ORIGINAL_SIZE

Revision 5e909a2c
Added by Daniel Molina over 3 years ago

feature #1727: Add extended template support in sunstone

Revision 9d68ab7c
Added by Daniel Molina over 3 years ago

feature #1727: Add range slider util

Revision 669e7885
Added by Daniel Molina over 3 years ago

feature #1727: Add disk resize in cloud view

Revision 0351583a
Added by Daniel Molina over 3 years ago

feature #1727: Add option to disable disk resize in cloud view

Revision ded50710
Added by Daniel Molina over 3 years ago

feature #1727: Check if size is greater than the original

Revision 3f61b184
Added by Carlos Martín over 3 years ago

Feature #1727: Use VM::disk_extended_info with temporary template objects

Revision e20441b4
Added by Daniel Molina over 3 years ago

feature #1727: Add resize disk to admin view

Revision b7d0db61
Added by Daniel Molina over 3 years ago

feature #1727: Update sunstone env param description

Revision f2ce88fc
Added by Ruben S. Montero over 3 years ago

feature #1727: Not use dynamic memory in method

Revision c10d0800
Added by Carlos Martín over 3 years ago

Feature #1727: Create new migrator for 4.13.85

Revision be70906b
Added by Carlos Martín over 3 years ago

Feature #1727: New option extend for java oca Template info

Revision 2d1b92fc
Added by Ruben S. Montero over 3 years ago

feature #1727: Rename disk_target to disk_tm_target

Revision de730869
Added by Carlos Martín over 3 years ago

Feature #1727: Add DISK/ORIGINAL_SIZE to restricted attributes

Revision 675dd15d
Added by Jaime Melis over 3 years ago

Feature #1727: Generic system to allow to resize
on onetemplate instantiate from the CLI

Revision f30d64aa
Added by Jaime Melis over 3 years ago

Feature #1727: Document adding extra attributes to disk and nic
on onetemplate instantiate

Revision 23f84d74
Added by Jaime Melis over 3 years ago

Feature #1727: add clone resize to ceph

Revision 8d40a75a
Added by Jaime Melis over 3 years ago

Feature #1727: Fix logic. Only resize of ORIGINAL_SIZE is defined
and if it's smaller than the desired size.

History

#1 Updated by Simon Boulet about 6 years ago

Attached patch allow images in USED and USED_PERS state to be resized.

Applies on top of image-resize.patch above.

Simon

#2 Updated by Ricardo Duarte about 6 years ago

This is a great feature.
virt-resize, from libguestfs, can be used to easily implement the actual resize on the driver.

http://libguestfs.org/virt-resize.1.html

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

  • Category set to Core & System

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

  • Priority changed from Normal to Low

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

Given the comments, I think this is better to be moved to the TM's. Images keep their potentially minimal size in the datastore. The TM then resizes the disk once the image is copied to the host, as described by #179.

In this case the interface would be:

DISK = [ IMAGE="Server CentOS", size="10GB" ]

The TM will then resize the image. Other considerations:

1.- Live resize of disk images won't be supported by all the TM's.
2.- It will only work for non-persistent images.

ALthough this issue (resize in the datastore) is slightly related, It may be better to go for the second option (resize on deployment, as in #179). Considering also the comments in #1768

Comments?

#6 Updated by Ricardo Duarte almost 6 years ago

Resize on deployment will work perfectly for #1768.

#7 Updated by Simon Boulet almost 6 years ago

Why not do both? Allow non-persistent image size to be specified at VM / template instantiation (independent of the initial data store image), and also have a method for updating persistent image size?

Currently all my images are persistent. I use the method in #1865 to tell my driver what final size the image is to be. My VM CREATE hooks picks up the new template and calls the one.image.resize (above patches) to set the size of the persistent image.

#9 Updated by Vladislav Gorbunov over 5 years ago

Could you tell me how to change the image size in one database from cli by using this path? Nedd to change the oneimage cli script?

#10 Updated by Vladislav Gorbunov over 5 years ago

I myself understood. Files with patches for resize image from command line (with oneimage) is in attachment. In datastore must be the script "resize" that do image resizing in datastore or return 0 exit code. Simon's path for OpenNebula 4.2 worked for OpenNebula 4.4.

#11 Updated by Ruben S. Montero about 5 years ago

  • Target version set to Release 4.6

#12 Updated by Ruben S. Montero about 5 years ago

  • Priority changed from Low to Normal

#13 Updated by Ruben S. Montero about 5 years ago

  • Related to Feature #179: Ability to expand disk source on physical host added

#14 Updated by Jaime Melis about 5 years ago

  • Target version changed from Release 4.6 to Release 4.8

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

  • Tracker changed from Feature to Backlog
  • Priority changed from Normal to High
  • Target version deleted (Release 4.8)

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

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

  • Status changed from New to Pending

#18 Updated by Jaime Melis about 4 years ago

  • Target version set to Release 4.12

#19 Updated by Ruben S. Montero about 4 years ago

  • Target version deleted (Release 4.12)

#20 Updated by Ruben S. Montero about 4 years ago

  • Target version set to Release 4.14

#21 Updated by Ruben S. Montero about 4 years ago

  • Tracker changed from Backlog to Feature

#22 Updated by Ruben S. Montero about 4 years ago

  • Status changed from Pending to New

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

  • Assignee set to Jaime Melis

#24 Updated by Stefan Kooman over 3 years ago

When resizing RAW images and or LVM backed virtual machines the following virsh command allows to update the new disk size to the live running VM:

virsh qemu-monitor-command one-ID --hmp "block_resize drive-virtio-disk0 size B". Where "drive-virtio-disk0" is the first disk of the virtual machine. To obtain a list of disks this command can be used "virsh qemu-monitor-command ONE-ID –hmp “info block”.

As these are "virsh" commands I guess there are equivalent libvirt API calls. It would be incredibly helpfull if this could be incorporated in "one.image.resize". It would make online resizing a breaze. If a image has (external) snapshots it should not be allowed to resize the disk in this manner, since the backing file is (expected to be) read-only.

#25 Updated by Stefan Kooman over 3 years ago

For some reason the "info block" command only works when I'm already in virsh shell:

virsh # qemu-monitor-command one-103 --hmp "info block"
drive-virtio-disk0: /var/lib/one//datastores/100/103/disk.0 (qcow2)

drive-ide0-0-0: /var/lib/one//datastores/100/103/disk.1 (raw, read-only)
Removable device: locked, tray closed

  1. virsh qemu-monitor-command one-103 --hmp “info block”
    unknown command: '“info'

#26 Updated by Stefan Kooman over 3 years ago

Resizing can be done more easily with "virsh blockresize" command or libvirt API call "virDomainBlockResize": https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainBlockResize

#27 Updated by Ruben S. Montero over 3 years ago

  • Tracker changed from Feature to Backlog
  • Status changed from New to Pending
  • Assignee deleted (Jaime Melis)
  • Target version changed from Release 4.14 to Release 5.0

4.14 implements the ability to expand (resize) disk images on hypervisors at VM deployment. This issue is kept for resizing images in the datastore.

#28 Updated by Carlos Martín over 3 years ago

  • Related to Bug #4073: Docs still mention VOLATILE_DISK instead of SYSTEM_DISK_SIZE added

#29 Updated by Ruben S. Montero about 3 years ago

  • Status changed from Pending to Closed
  • Target version deleted (Release 5.0)

Created a new issue for this #4274

Also available in: Atom PDF