Race condition when allocating IP addresses to host objects
Closed this issue · 2 comments
Finding an unused IP address and assigning it to a host object is a two-step process.
If done via the API, by a script or automated process that works with parallel threads, there is a race condition where the same IP address can be assigned to more than one host object.
Technically this is also possible by two actors using mreg-cli
simultaneously, although this is much less likely to occur.
A solution is to create a new API endpoint that both finds and reserves an IP address (and that properly locks resources internally while doing so).
This is mentioned in #396
If I remember correctly:
Adding a host to a network is a one step process. But there is still a very, very, tiny, slight possibility for a race condition. (I.E there is a race condition in the code and not due to it being a two step process)
Oh, so this already works. Jolly good then. Closing the issue