Skip to content

Commit 85d0f8f

Browse files
Sakshamsmurali-reddy
authored andcommitted
CLOUDSTACK-5916: associateIpAddress leaves an IP in allocating state
1 parent 20fd276 commit 85d0f8f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎server/src/com/cloud/network/NetworkServiceImpl.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3865,10 +3865,16 @@ public IpAddress associateIPToNetwork(long ipId, long networkId) throws Insuffic
38653865

38663866
Network network = _networksDao.findById(networkId);
38673867
if (network == null) {
3868+
// release the acquired IP addrress before throwing the exception
3869+
// else it will always be in allocating state
3870+
releaseIpAddress(ipId);
38683871
throw new InvalidParameterValueException("Invalid network id is given");
38693872
}
38703873

38713874
if (network.getVpcId() != null) {
3875+
// release the acquired IP addrress before throwing the exception
3876+
// else it will always be in allocating state
3877+
releaseIpAddress(ipId);
38723878
throw new InvalidParameterValueException("Can't assign ip to the network directly when network belongs" + " to VPC.Specify vpcId to associate ip address to VPC");
38733879
}
38743880
return _ipAddrMgr.associateIPToGuestNetwork(ipId, networkId, true);

0 commit comments

Comments
 (0)