ansible-community / molecule-libvirt

Molecule LibVirt Provider
https://github.com/ansible-community/molecule-libvirt/issues/13#issuecomment-1372615418
MIT License
35 stars 19 forks source link

virt-resize: error: You cannot use --expand when there is no surplus space #24

Closed ssbarnea closed 3 years ago

ssbarnea commented 3 years ago

Apparently I went into:

TASK [Create an image shell with the desired size] ***********************************************************************************************************
changed: [localhost] => (item=instance)

TASK [Expand original image on the new sized volume] *********************************************************************************************************
failed: [localhost] (item=instance) => {"ansible_loop_var": "item", "changed": true, "cmd": "umask 0002\nvirt-resize --quiet --expand /dev/sda1 instance.qcow2 instance-temp.qcow2\n", "delta": "0:00:02.332616", "end": "2021-05-16 11:42:46.732044", "item": {"name": "instance"}, "msg": "non-zero return code", "rc": 1, "start": "2021-05-16 11:42:44.399428", "stderr": "virt-resize: error: You cannot use --expand when there is no surplus space \nto expand into.  You need to make the target disk larger by at least 32.0K.\n\nIf reporting bugs, run virt-resize with debugging enabled and include the \ncomplete output:\n\n  virt-resize -v -x [...]", "stderr_lines": ["virt-resize: error: You cannot use --expand when there is no surplus space ", "to expand into.  You need to make the target disk larger by at least 32.0K.", "", "If reporting bugs, run virt-resize with debugging enabled and include the ", "complete output:", "", "  virt-resize -v -x [...]"], "stdout": "", "stdout_lines": []}

If I understand correctly, resize should be called only when needed and calling it when image is already at correct size would produce this error.

jamesregis commented 3 years ago

@ssbarnea I'm unable to reproduce this error. Can you tell me in which configuration it comes ?

goldyfruit commented 3 years ago

We discussed with @jamesregis about this, @jamesregis will had a creates argument to the resize.

jamesregis commented 3 years ago

Looks like "mol create" command was launched while there was still a qcow2 image present, on which virt-resize attempted to run. This is a very rare case, when the hypervisor takes a long time to destroy the virtual machine and you restart the VM creation. Maybe we should add a check when destroying .. that will probably be the subject of another PR.