knife-vsphere icon indicating copy to clipboard operation
knife-vsphere copied to clipboard

knife vsphere vm vmdk add - last 10% hard-coded

Open gitfirenz opened this issue 8 years ago • 10 comments

Hello,

(I'm using a lot your work today :) )

There is an "issue" : When you add a disk, you check if, after the creation of the disk, it will remain 10% of the disk capacity. I understand the need for a protection.

Buuut :

  • 10% is a lot (i'm working on a 7To datastore), so it should be configurable
  • at least as a quick fix, the error should talk about this 10%.

gitfirenz avatar Jul 31 '15 15:07 gitfirenz

I think I know what you're talking about, but can you paste a command and output, please? We can make it configurable and leave a 10% default, as I agree, a percentage has little meaning when the size of the volume varies so much.

(Also, I'm out for a week, so won't be responding much until after the 8th)

swalberg avatar Jul 31 '15 16:07 swalberg

Here's an output :

sudo knife vsphere vm vmdk add my_vm_01 20
Datastore: datastoreSAN (25.86 GB(27762098176) / 139.75 GB)
Insufficient space on all LUNs designated or assigned to the virtual machine. Please specify a new target.

I asked 20g, 25.86 left, but it is not enough :(

It comes from "def choose_datastore(dstores, size)" in base_vsphere_command.rb with thses lines (243) :

# also let's not use more than 90% of total space to save room for snapshots.
          cap_remains = 100 * ((store.summary[:freeSpace].to_f - vmdk_size_b.to_f) / store.summary[:capacity].to_f)
          candidates.push(store) if cap_remains.to_i > 10

In line 250 : puts 'Insufficient space on all LUNs designated or assigned to the virtual machine. Please specify a new target.' The best would be to put the 10% in the knife config (so i can decide 0%, 0,1% etc).

gitfirenz avatar Aug 04 '15 13:08 gitfirenz

any update on this?

bathenme avatar Jul 11 '17 14:07 bathenme

Same happens if you try to add a thin provisioned disk to a VM but the requested initial size is bigger than the available minus 10%.

So if you have 1.71TB available and you want to add a 2TB thin provisioned disk, then it fails:

Datastore: <DSNAME> (1.71 TB(1877164412928) / 10.00 TB)
Insufficient space on all LUNs designated or assigned to the virtual machine. Please specify a new target.

Same works via the vCenter vSphere thick client as you are adding a thin provisioned disk so the free space at the moment of adding should not be a concern.

Thanks, -N

nkichukov avatar Apr 24 '18 14:04 nkichukov

Hi, I remember working on this one then pausing, but I don't remember why. I think I may just remove that 10% check altogether.

swalberg avatar Apr 24 '18 15:04 swalberg

The 10% check is not exactly what I had in mind. It needs to go away anyways, but mine is different. It is to do with the type of disk and the available storage.

If adding THICK disk, the current state is safe, but if that is THIN, the current state needs to be able to consider this and proceed(due to thin) even though not enough space is reported to exist.

Thank you, -N

nkichukov avatar Apr 24 '18 15:04 nkichukov

Oh, you want to be able to overprovision using thin? That makes sense. Sorry for my slowness here, this command is among the ones I don't understand fully and don't want to make changes that break other people's workflow. I think I can do this one without breaking things.

swalberg avatar Apr 24 '18 15:04 swalberg

Are you able to pull down my branch and test this locally?

https://github.com/swalberg/knife-vsphere/tree/vmdk_add_thin

swalberg avatar Apr 24 '18 15:04 swalberg

Yes, I can do that. Once I have the time to switch again into this, I will definitely give it a try and report back my results. Thank you! -Nik

nkichukov avatar Apr 25 '18 16:04 nkichukov

Hello, sorry for the long delay in testing this. I can confirm that the feature does allow one to add a thin-provisioned disk that not only exceeds the current free space on the selected datastore, but also allows to extend beyond the size of the whole datastore.

In the example below, I have managed to add 10000GB thin vmdk disk to a VM where the overall available size on the datastore was: 7.81 TB.

So for me this is resolved. Thank you! See test below:

knife-vsphere-test]$ knife vsphere vm vmdk add --vmdk-type thin mytestvm 10000G Datastore: mytestdatastore (7.74 TB(8512542343168) / 7.81 TB) Choosing: mytestdatastore here VirtualMachine("vm-1933") [mytestdatastore] mytestvm/mytestvm.vmx [mytestdatastore] mytestvm/mytestvm.vmxf [mytestdatastore] mytestvm/mytestvm.nvram [mytestdatastore] mytestvm/mytestvm.vmsd [mytestdatastore] mytestvm/mytestvm.vmdk [mytestdatastore] mytestvm/mytestvm-flat.vmdk [mytestdatastore] mytestvm/mytestvm_1.vmdk [mytestdatastore] mytestvm/mytestvm_1-flat.vmdk [mytestdatastore] mytestvm/mytestvm_2.vmdk [mytestdatastore] mytestvm/mytestvm_2-flat.vmdk [mytestdatastore] mytestvm/mytestvm-d95dbafd.vswp [mytestdatastore] mytestvm/vmx-mytestvm-3646798589-1.vswp [mytestdatastore] mytestvm/vmware-1.log [mytestdatastore] mytestvm/vmware-2.log [mytestdatastore] mytestvm/vmware.log Next vmdk name is => [mytestdatastore] mytestvm/mytestvm_3.vmdk Creating VMDK Capacity: 10000G GB Disk: [mytestdatastore] mytestvm/mytestvm_3.vmdk Attaching VMDK to mytestvm using SCSI controller 0 using SCSI ID 3

and knife-vsphere v2.1.1 which came preinstalled with chefdk-3.2.30-1.el6.x86_64.rpm and I reinstalled from the gem I built from https://github.com/swalberg/knife-vsphere/tree/vmdk_add_thin (not sure if those are the same or not because the versions matched): knife-vsphere-test]$ chef gem list | grep knife-vsphere knife-vsphere (2.1.1)

Thank you! -N

nkichukov avatar Sep 21 '18 13:09 nkichukov