Skip to content
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

[Feature Request] Non destructive volume resize #952

Open
1 of 5 tasks
Hybrid512 opened this issue May 23, 2022 · 6 comments
Open
1 of 5 tasks

[Feature Request] Non destructive volume resize #952

Hybrid512 opened this issue May 23, 2022 · 6 comments

Comments

@Hybrid512
Copy link

System Information

Linux distribution

Ubuntu 20.04/22.04

Terraform version

Terraform v1.0.11 on linux_amd64

Provider and libvirt versions

terraform-provider-libvirt 0.6.14

Checklist

  • Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?

    • Make sure you explain why this option is important to you, why it should be important to everyone. Describe your use-case with detail and provide examples where possible.
    • If it is a very special case, consider using the XSLT support in the provider to tweak the definition instead of opening an issue
    • Maintainers do not have expertise in every libvirt setting, so please, describe the feature and how it is used. Link to the appropriate documentation
  • Is it a bug or something that does not work as expected? Please make sure you fill the version information below:

Description of Issue/Question

Terraform can detect state differences between an existing volume size and an expected new volume size but with the current libvirt provider, volumes are first deleted then re-created with the new size.
This is ok for reproductible and immutable environments but this is annying especially when you have big volumes or data you would like to avoid losing or restoring (repository mirroring, datasets, ...).
Libvirt enable resizing a volume without destrying/re-creating it, I can do it easily with virsh just like this :

virsh vol-resize <MyVolume> <NewSizeInBytes> --pool <MyVolumePool>

Only conditions for that :

  • VM must be stopped
  • new volume size can't be smaller than original size (can only expand, not shrink)

Steps to Reproduce Issue

Any VM with at least a volume

@jtackaberry
Copy link

It's actually possible to do an online resize with libvirt:

virsh blockresize somevm --path /vms/somevm-root.qcow2 --size 10G

And this is detected immediately within the guest:

[  267.339414] virtio_blk virtio2: [vda] new size: 20971520 512-byte logical blocks (10.7 GB/10.0 GiB)
[  267.339423] vda: detected capacity change from 12582912 to 20971520

I'd love to see this possible via terraform-provider-libvirt too.

@JSmith-Aura
Copy link

I'd love to see this as well, would make life a lot more fun (also thanks for all the work you do on this project)

@merlinfvr
Copy link

@dmacvicar would you accept a PR for this issue? Being able to resize volumes non-destructively would be great.

Libvirt already supports this via virStorageVolResize and virDomainBlockResize. It seems the former works on any volume not currently attached to a running domain while the latter supports resizing on a running domain (but presumably does not work on volumes not currently attached to a domain as it requires a reference to one).

Is there any way to easily check if a volume is currently attached to a (and if yes, which) domain? Looping all domains to check if they have a specific volume attached will be very inefficient.

@scabala
Copy link
Contributor

scabala commented Sep 5, 2024

Related to #1017

Lots of useful information in this issue!

@merlinfvr are you interested in creating a PR for this?

@dmacvicar
Copy link
Owner

I think this could be done in the Update section. If it is done in a clean way and the code does not result to be complicated.

@NamelessOne91
Copy link

Hello there

I've started to put together something at #1122
Feedback and ideas would be greatly appreciated :)

So far, it seems to work in simple and straightforward use cases. I'm pretty sure there is a number of additional checks and conditions that can, and should, be added.
Having someone expert on the matter that can point them out would really help and, time permitting, I can give a shot at implementing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants