Ensure that many disks can be created
https://github.com/saltstack/salt/issues/60564
Like mentioned in that issue, when a device is created with disks we should increment. Alternatively if we really need random instead of sequential, we should just shuffle the list and pop items off instead.
Also, note that this behavior affects network adapters as well. Everywhere the 'random_key' var is used in the original clouds/vmware.py source.
I've been hit by this on 3006.6, too, and ou'll likely see the same problem with 3007.1, too (the code hasn't changed). It appears to be a significant issue, we're creating VMs automatically and when there are more than two disks per VM, I've been struck with this error quite a number of times in two days (and that's just test operations, where we initiate VM creation at a rate no higher than one per minute, most often much less). I've had cases where we had to re-run the creation job three times until it worked out without this error.
As in my specific case new processes are forked for each build, I resorted to to remembering the already used keys and keep retrying until a fresh one is found. I only now read above that incremental keys would be fine, too.
rand_disk_keys = []
...
random_key = randint( -2099, -2000)
while random_key in rand_disk_keys:
random_key = randint( -2099, -2000)
rand_disk_keys.append( random_key)
If the process instance would be living longer than per-job, some automatic means to clean the cache(s) (or re-init the sequence(s) ) on the start of each individual job) would need to be found.