-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cs instance root_disk size update resizes the root volume #43817
Conversation
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch> Reviewed-by: Marc-Aurèle Brothier <m@brothier.org>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
The test
|
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
|
||
if root_disk_size is not None: | ||
res = self.query_api('listVolumes', type='ROOT', virtualmachineid=instance['id']) | ||
[volume] = res['volume'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we catch a just in case missing volume in the response to be cleaner?:
volume = res.get('volume')
if volume:
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defensive programming doesn't help figuring it out what's wrong, in case something is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
Thanks for the contribution. code looks good to me. One thing I don't like that much is the param name |
You're right we need something more meaningful to relate to the root disk of the VM since we are in the instance module. I'd prefer the |
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
if shrinkok: | ||
args_volume_update['shrinkok'] = shrinkok | ||
|
||
root_disk_size_changed = root_disk_size != size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more question, this would also be "true" for enlargement of the disk, would this work as expected? if yes, allow_root_disk_shrink
would be a misleading name because it would not only resize to smaller, but also resize to bigger volume --> allow_root_disk_resize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's really only for _shrinkagethat a special flag needs to be sent.
allow_root_disk_resize` would be misleading as the nothing special is required for enlarging a disk.
http://cloudstack.apache.org/api/apidocs-4.4/user/resizeVolume.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@resmo the shrink option is only for changing the disk size to a smaller partition. It requires more actions from the user if it should success:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, that means, we should change this condition to the following, right?
root_disk_size_changed = root_disk_size < size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you can resize the volume up or down, but if you want to resize it down you must specify the flag shrink
to ensure you know what you are doing since it requires some preparation of the volume.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, got it! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs_info
rebuild_merge |
bot_status |
Componentslib/ansible/modules/cloud/cloudstack/cs_instance.py Metadatawaiting_on: maintainer |
rebuild_merge |
SUMMARY
CloudStack's resizeVolume on the
ROOT
volume of a VM based on theroot_disk_size
.ISSUE TYPE
COMPONENT NAME
cloud / cloudstack / cs_instance
ANSIBLE VERSION
ADDITIONAL INFORMATION
Assuming, you created an instance with a
root_disk_size
or based on a template supporting it. Changing its value will triggers aresizeVolume
call applying the changes.shrinkok
is an extra option.