Damans227 commented on code in PR #14348:
URL: https://github.com/apache/cloudstack/pull/14348#discussion_r4223206729
##########
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java:
##########
@@ -420,22 +420,21 @@ private IPAddressVO assignAndAllocateIpAddressEntry(final
Account owner, final V
}
private IPAddressVO assignIpAddressWithLock(IPAddressVO possibleAddr) {
- IPAddressVO finalAddress = null;
- IPAddressVO userIp =
_ipAddressDao.acquireInLockTable(possibleAddr.getId());
- if (userIp != null) {
- logger.debug("locked row for ip address {} (id: {})",
possibleAddr.getAddress(), possibleAddr.getUuid());
- if (userIp.getState() == State.Free) {
- possibleAddr.setState(State.Allocating);
- if (_ipAddressDao.update(possibleAddr.getId(), possibleAddr)) {
- logger.info("successfully allocated ip address {}",
possibleAddr.getAddress());
- finalAddress = possibleAddr;
- }
- } else {
- logger.debug("locked ip address {} is not free {}",
possibleAddr.getAddress(), userIp.getState());
- }
- _ipAddressDao.releaseFromLockTable(possibleAddr.getId());
+ IPAddressVO userIp = _ipAddressDao.lockRow(possibleAddr.getId(), true);
+ if (userIp == null) {
+ return null;
+ }
+ logger.debug("locked row for ip address {} (id: {})",
possibleAddr.getAddress(), possibleAddr.getUuid());
+ if (userIp.getState() != State.Free) {
+ logger.debug("locked ip address {} is not free {}",
possibleAddr.getAddress(), userIp.getState());
+ return null;
Review Comment:
the list passed in here only has one ip, so does the losing system vm now
fail with a no free ip error even when other ips are free? could we try the
next free ip instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]