Open eliasp opened 6 months ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @Ajpantuso @Thulium-Drake @UnderGreen @helldorado @joshainglis @karmab @krauthosting click here for bot help
(we had a discussion on this before @eliasp created this issue in #devel:ansible.com on Matrix; if someone is interested in the discussion, the logs for that room are public IIRC)
Summary
When using
community.general.proxmox_kvm
to create multiple VMs at once, only one VM will always succeed, the others might randomly fail to be created due to thevmid
being re-used:creation of qemu VM ansible-vm-test4 with vmid 108 failed with exception=500 Internal Server Error: unable to create VM 108 - VM 108 already exists on node '[REDACTED]'
Issue Type
Bug Report
Component Name
proxmox_kvm
Ansible Version
Community.general Version
Configuration
OS / Environment
RedHat UBI9.3 Container as Execution Environment Proxmox 8.1.4 as target
Steps to Reproduce
When trying to create multiple Proxmox KVM VMs at the same time, only the creation of 1 VM will reliably succeed. All subsequent VMs fail in most cases, sometimes a 2nd or 3rd one can be created.
hosts.yml
playbook.yml
Execution:
ansible-playbook -vv -i hosts.yml playbook.yml
Expected Results
I expected
community.general.proxmox_kvm
to be able to create multiple VMs at once without failing.Actual Results
This is caused by:
community.general.proxmox_kvm
having to provide thevmid
to Provmox VE, because it can't determine it on its own during VM creation, it's a required parametercommunity.general.proxmox_kvm
determining the next availablevmid
at the same time as the other instances ofcommunity.general.proxmox_kvm
processing this taskSince
vmid
is a required parameter of the PVE API, it needs to be determined by the API client (e.g. in contrast to the vSphere VMOMI API, where thevmoid
is generated by the server upon VM creation). This introduces a race condition in our scenario, where multiple processes creating VMs at the same time fight within the window of "determinevmid
by querying PVE API for the next available one" and "create VM using thevmid
" to be the first one.The only reasonable fix, is to catch the API response and retry on a failure with another
vmid
until the VM creation succeeds.A workaround for users for now is to set
throttle: 1
for the corresponding task to prevent multiple processes to run at the same time:Code of Conduct