[salt-cloud] Attribution of floating IPs works partially in parallel mode
salt-cloud is working fine for my use case in "normal" (sequential) mode.
When I do the same thing with "-P" only one of the machines in the map gets a floating IP attributed, so the other machines never get to be accessed and the thing runs in a loop (I guess there's a timeout).
Am using it against an openstack installation.
can you provide your map?
debian_wheezy_small:
- django-db
- django-web1
- django-web2
- django-web3
Sorry, Also need the cloud.profile and your provider, where ever you have your floating IP addresses set. I will try and look at this in a bit, I need to re setup my openstack environment.
nevermind, I will look at this while working on #12223 @gtmanfred
I hit the same problem and I think I was able to track it down.
The problem is that salt-cloud uses a pool.list_floating_ips() call to get a list of floating IPs and then it confirms whether the IP has been assigned to an instance by checking the node_id property (see below).
for idx in pool.list_floating_ips():
if idx.node_id is None:
floating.append(idx)
if not floating:
When running in parallel mode this leads to a race condition, so what happens is that instances get the very same floating IP attached. On the other hand, OpenStack will not allow a floating IP to be shared by multiple instances, hence the final result is one instance with a floating IP and the rest without.
A quick hackish fix is to change the pool.list_floating_ips() call with pool.create_floating_ip() (see below)
- for idx in pool.list_floating_ips():
+ for idx in [pool.create_floating_ip()]:
if idx.node_id is None:
floating.append(idx)
if not floating:
After that, I can confirm that floating IPs will be allocated to all instances correctly.
Does create_floating_ips create a new one each time? or will it grab an unallocated ip first?
Thanks Daniel
Hi Daniel, Sorry for such a late response.
Yes, if create_floating_ip() is used, a new floating ip will be allocated each time a vm is created. No ideal, but I reckon is better that have instances without floating ip.