(I am using openstack4j to talk to OpenStack via REST API)
I would like to reuse some of the unassigned floating IPs allocated in my tenant (allocate to newly provisioned servers). However, it seems that addFloatingIp
action makes no difference between assigning unused floating IP and reassigning it from server to server.
I would like to automate the process but I am afraid of following race condition: one client check particular IP is free and before it manages to associate it with server A, other client associate it with server B. From the perspective of the second client, the associated floating IP can be removed in any later point after successfully associated.
Is there any better way?
The challenges in question concern usage of (now deprecated) Floating IP extension of Compute service that splits floating IP allocation into two steps: allocation (/os-floating-ips
endpoint) and assignment (addFloatingIp
server action).
Currently supported way is to manipulate floating IPs via Neutron service that permits to create and associate floating IPs in one request (POST
to /v2.0/floatingips
). This, at least in theory, eliminates the possibility of a client that desire to reuse a floating IP would take one being associated by some other client as the same time. Provided all clients agree to use this mode of Floating IP assignment, unassociated Floating IPs are safe to dispose as dangling entitie.