mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: add logs to public ip allocation attempt (#8239)
This commit is contained in:
parent
405aac38bc
commit
0577b0ac8e
@ -343,6 +343,9 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
if (possibleAddr.getState() != State.Free) {
|
if (possibleAddr.getState() != State.Free) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("trying ip address %s", possibleAddr.getAddress()));
|
||||||
|
}
|
||||||
possibleAddr.setSourceNat(sourceNat);
|
possibleAddr.setSourceNat(sourceNat);
|
||||||
possibleAddr.setAllocatedTime(new Date());
|
possibleAddr.setAllocatedTime(new Date());
|
||||||
possibleAddr.setAllocatedInDomainId(owner.getDomainId());
|
possibleAddr.setAllocatedInDomainId(owner.getDomainId());
|
||||||
@ -357,17 +360,11 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
possibleAddr.setAssociatedWithNetworkId(guestNetworkId);
|
possibleAddr.setAssociatedWithNetworkId(guestNetworkId);
|
||||||
possibleAddr.setVpcId(vpcId);
|
possibleAddr.setVpcId(vpcId);
|
||||||
}
|
}
|
||||||
if (_ipAddressDao.lockRow(possibleAddr.getId(), true) != null) {
|
finalAddress = assignIpAddressWithLock(possibleAddr);
|
||||||
final IPAddressVO userIp = _ipAddressDao.findById(possibleAddr.getId());
|
if (finalAddress != null) {
|
||||||
if (userIp.getState() == State.Free) {
|
|
||||||
possibleAddr.setState(State.Allocating);
|
|
||||||
if (_ipAddressDao.update(possibleAddr.getId(), possibleAddr)) {
|
|
||||||
finalAddress = possibleAddr;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (finalAddress == null) {
|
if (finalAddress == null) {
|
||||||
s_logger.error("Failed to fetch any free public IP address");
|
s_logger.error("Failed to fetch any free public IP address");
|
||||||
@ -387,6 +384,29 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IPAddressVO assignIpAddressWithLock(IPAddressVO possibleAddr) {
|
||||||
|
IPAddressVO finalAddress = null;
|
||||||
|
IPAddressVO userIp = _ipAddressDao.acquireInLockTable(possibleAddr.getId());
|
||||||
|
if (userIp != null) {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("locked row for ip address %s (id: %s)", possibleAddr.getAddress(), possibleAddr.getUuid()));
|
||||||
|
}
|
||||||
|
if (userIp.getState() == State.Free) {
|
||||||
|
possibleAddr.setState(State.Allocating);
|
||||||
|
if (_ipAddressDao.update(possibleAddr.getId(), possibleAddr)) {
|
||||||
|
s_logger.info(String.format("successfully allocated ip address %s", possibleAddr.getAddress()));
|
||||||
|
finalAddress = possibleAddr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (s_logger.isDebugEnabled()) {
|
||||||
|
s_logger.debug(String.format("locked ip address %s is not free (%s)", possibleAddr.getAddress(), userIp.getState()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ipAddressDao.releaseFromLockTable(possibleAddr.getId());
|
||||||
|
}
|
||||||
|
return finalAddress;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) {
|
public boolean configure(String name, Map<String, Object> params) {
|
||||||
// populate providers
|
// populate providers
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user