Closed ischeinkman closed 1 month ago
Thanks for reporting this @ischeinkman.
by polling the results refresh_devices_list and checking that all devices returned match their requirements, but refresh_devices_list only returns devices visible from the API without checking to see if that includes all the device IDs passed as a parameter.
Actually, it looks like refresh_devices_list
is correctly filtering the list of results to those matching the devices specified (by id).
The bug here is in the "all". As a vacuous truth the condition is met. We can add a len()
check to ensure that the expected number of refreshed devices are found.
>>> if all(d == 1 for d in []):
... print("yes")
...
yes
Actually, it looks like refresh_devices_list is correctly filtering the list of results to those matching the devices specified (by id).
Yes, that is true. What I was referring to was that refresh_devices_list
only returns entries found in the list of results returned from module.get_devices()
. If a devices passed in the initial devices
list cannot be found in the return value of module.get_devices()
then the function will not include an entry for that device ( as opposed to doing something like creating a Device
object with a state
of deleted
/deprovisioned
or something to that effect ).
Sorry that I wasn't clear!
SUMMARY
There seems to be a race condition when provisioning a new device and waiting for the provisioning to complete (either via setting
state: active
or viawait_for_public_IPv: 4/6
). Specifically, if the device disappears from the active devices list while waiting for either of those conditions, theequinix.metal.device
module will success with an empty device list instead of failing. This can happen, for example, when attempting to provision a new host with the same hostname as a host in the process of being de-provisioned.This seems to be due to the fact that the
wait_for_devices_active
andwait_for_public_IPv
functions attempt to wait for their conditions to be met by polling the resultsrefresh_devices_list
and checking that all devices returned match their requirements, butrefresh_devices_list
only returns devices visible from the API without checking to see if that includes all the device IDs passed as a parameter.ISSUE TYPE
COMPONENT NAME
equinix.metal.device
STEPS TO REPRODUCE
Provision a server with the following play:
Begin a de-provisioning of that server, either via the web UI or via setting
state
toabsent
on the above play.Before the de-provisioning of the host created in Step 1 completes, re-run the above play.
EXPECTED RESULTS
Either the module to throw an error or to wait for the previous host to finish de-provisioning before attempting to re-provision.
ACTUAL RESULTS
The play succeeds, except
output.devices
is empty.