terraform-provider-vsphere icon indicating copy to clipboard operation
terraform-provider-vsphere copied to clipboard

Add support to resize `r/vsphere_virtual_disk`

Open jsmilani opened this issue 5 years ago • 32 comments

Right now the vsphere_virtual_disk resource does not permit any changes, but we need to increase disk size on occasion. It is unreasonable to expect us to find a manual workaround to copy data from an old disk to a new larger disk. I would understand requiring a new disk when decreasing the size since that is generally not possible on most systems. During our tests we found the 'eagerZeroedThick' type does not allow resizing by vSphere but 'lazy' should permit increases in size.

NOTE: All fields in the vsphere_virtual_disk resource are currently immutable and force a new resource if changed.

Terraform Version

0.12.x

vSphere Provider Version

1.12.0

Affected Resource(s)

Please list the resources as a list, for example:

  • vsphere_virtual_disk

Expected Behavior

We expect to be able to increase the size of a type='lazy' vsphere_virtual_disk.

Actual Behavior

Disk wants to be recreated and we will lose all data.

jsmilani avatar Sep 27 '19 22:09 jsmilani

@jsmilani this appears to be a duplicate of #150

aareet avatar Oct 01 '19 19:10 aareet

#150 mentions resizing 10 comments deep, but it is phrased as a question. I don't think it qualifies as a duplicate since the original message itself doesn't address resizing nor does its proposed solution. I believe resizing doesn't necessarily require stopping the VM, but I have not figured out how to do that in the vcenter UI yet.

jsmilani avatar Oct 01 '19 20:10 jsmilani

I just wanted to clarify that it doesn't need to be 'lazy' to resize, both 'lazy' and 'eagerZeroedThick' are confirmed resizable but I have not tested 'thin'. Resizing works while it is mounted to a running vsphere_virtual_machine, but the volume still needs to be manually expanded (this is normal and expected). It doesn't seem to work at all when it is mounted to a vsphere_virtual_machine with the disk_sharing='sharingMultiWriter' option.

jsmilani avatar Oct 01 '19 21:10 jsmilani

This issue has been open 180 days with no activity. If this issue is reproducible with the latest version of the provider and with Terraform 0.12, please comment. Otherwise this issue will be closed in 30 days.

hashibot avatar Apr 21 '20 00:04 hashibot

Adding comment to keep this alive. It is very much an issue still.

jsmilani avatar Apr 21 '20 00:04 jsmilani

Issue is happening in 0.12.23

Vox1984 avatar May 20 '20 08:05 Vox1984

Hello Colleagues, we are still facing this issue as mentioned in below comment can this be done to help us to resize the disk provisioned by vsphere_virtual_disk resource. https://github.com/hashicorp/terraform-provider-vsphere/issues/150#issuecomment-528105175

We need to use the disk for logsearch and cassandra for which resizing will be regularly required..

Karthikeyanraman94 avatar Jul 10 '20 08:07 Karthikeyanraman94

@bill-rich: Could you please help in taking forward this enhancement request

Karthikeyanraman94 avatar Jul 10 '20 08:07 Karthikeyanraman94

I notice there's no resourceVSphereVirtualDiskUpdate function in the vsphere/resource_vsphere_virtual_disk.go file. To accomplish this, would it just require someone to implement the ability to diff the configuration in the file via a couple of conditionals?

arizvisa avatar Aug 07 '20 00:08 arizvisa

Also interested in having the ability to resize vsphere_virtual_disks. We have virtual machines with "external" created disks as data disks and sometimes we need to resize them and have to do some dirty hacks with manipulating the terraform state.

dcardellino avatar Aug 18 '20 06:08 dcardellino

@dcardellino, please +1 the first comment in this issue so your request reaches hashicorp's analytics (or whatever they're doing).

arizvisa avatar Aug 18 '20 22:08 arizvisa

@dcardellino very much a issue we need addressing as well. Any timeline for this ? Thanks

mouradk78 avatar Oct 21 '20 16:10 mouradk78

+1 here

angelbarrera92 avatar Jan 12 '21 07:01 angelbarrera92

Any Update here?

dcardellino avatar Feb 08 '21 07:02 dcardellino

Any update ?

armand-s2h avatar Jun 22 '21 13:06 armand-s2h

Any Update

garvitpatel196 avatar Jul 09 '21 17:07 garvitpatel196

Struggling to find a way to resize disk partition with terraform for VM created from packer template.

rihenperry avatar Jul 27 '21 02:07 rihenperry

@rihenperry, you can script the govc client using the vm.disk.change parameter until you or someone else submits a PR to get the implementation of this feature jumpstarted.

arizvisa avatar Jul 27 '21 07:07 arizvisa

any updates on resizing disks, we really want need this feature.

magnusstrandberg1 avatar Nov 01 '21 15:11 magnusstrandberg1

Has anyone got any suggestions, we clone from a template VM with a 30GB didk to a 50GB disk, the VM shows as having a 50 GB disk but cant see the free space anywhere in the rhel VM to extend logical volumes ?

keelerad avatar Dec 15 '21 10:12 keelerad

+1

ichundu avatar Jan 05 '22 09:01 ichundu

+1

magnusstrandberg1 avatar Jan 11 '22 15:01 magnusstrandberg1

Ugh. As a reminder, please do not put "+1" as an additional comment. nobody will _ever_ see that shit unless they're already part of the issue in question... you need to +1 the original post.

arizvisa avatar Jan 11 '22 15:01 arizvisa

Please be mindful of language and the code of conduct.

tenthirtyam avatar Jan 11 '22 18:01 tenthirtyam

Isnt this always a problem to be solved by a provisioner with access to the os running/using the disks ?

In linux you would rescan the scsi bus and resize the disks via something like

echo 1 > /sys/class/scsi_disk/2\:0\:0\:0/device/rescan # adjust device number
growpart /dev/sda 2 
# then for lvm
pvresize /dev/sda2 
lvextend -l+100%FREE /dev/srv-git-vg/root
resize2fs /dev/mapper/srv--git--vg-root

# or for normal partitions
resize2fs /dev/sda2

I think you can even do this via cloud-init on boot ?

In Windows this can be done by powershell as well if i remember correctly...

TLDR I think there are two issues mixed up here...

  • Resizing exitings vm disks
  • Resising filesystems in a vm
  • Resizing different types of vm disks

The first is working with terraform at least with thin prov disks for me. I second is outside the scope of the vsphere-provider as it require different commands/tools depending on the used disk layouts and filesystems

If this issue is only about the third variant, the subject of the issue should be adjusted to reflect that

erSitzt avatar Jan 25 '22 14:01 erSitzt

The OS maps the device to a physical volume and then to a logical volume so it is true that it must get involved to make the actual volume increase in size, but the prerequisite is the device has been resized first and that is done by VSphere by modifying the virtual disk. We are not asking to solve the OS side of the problem, but we want to be able to increase the virtual disk size via terraform. Right now the workaround is to manually increase the disk size in the VCenter UI then update the terraform resource to match the manual change. We want to just be able to update the terraform resource to increase disk (not decrease). Decreasing size is outside of scope since it would destroy the volume if the OS had already claimed the new space.

jsmilani avatar Jan 25 '22 19:01 jsmilani

@jsmilani Yeah, i misread something here... my bad, sorry...

can i downvote my own comment ? :)

erSitzt avatar Jan 25 '22 19:01 erSitzt

Votes are only counted on the original description issue

tenthirtyam avatar Jan 25 '22 19:01 tenthirtyam

Somewhat related, when doing a terraform destroy after updating a template that has a different sized vmdk, terraform fails with error. Is it possible to have the delete action ignore this specific error?

Error: disk.0: virtual disk "disk0": virtual disks cannot be shrunk (old: 150 new: 78) with vsphere_virtual_machine.vm[0], on main.tf line 78, in resource "vsphere_virtual_machine" "vm":

RobertCGouge avatar Sep 16 '22 14:09 RobertCGouge

It’s been 3 years now. 28 votes so far. How many does it need to get this going? I know this is voluntarily work and I wish I could PR this (don’t get it to work) … But we still have to use a workarounds while it works perfectly with defined disks in r/vsphere_virtual_machine already. Which is also not about the OS side!

scryptio avatar Nov 27 '22 16:11 scryptio