Skip to content

Commit 0e3ddb2

Browse files
authored
CLOUDSTACK-9595: Fix regression introduced in #1762 (#2370)
The `assignDedicateIpAddress` previously had marked the newly fetched IP as allocated but now it does not do that. This fails for VPCs where SNATs IP are retained as allocating and not allocated after creation. Signed-off-by: Rohit Yadav <[email protected]>
1 parent 80a6961 commit 0e3ddb2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

server/src/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
291291

292292
SearchBuilder<IPAddressVO> AssignIpAddressSearch;
293293
SearchBuilder<IPAddressVO> AssignIpAddressFromPodVlanSearch;
294-
private final Object _allocatedLock = new Object();
295-
private final Object _allocatingLock = new Object();
294+
private static final Object allocatedLock = new Object();
295+
private static final Object allocatingLock = new Object();
296296

297297
static Boolean rulesContinueOnErrFlag = true;
298298

@@ -834,7 +834,7 @@ public IPAddressVO doInTransaction(TransactionStatus status) throws Insufficient
834834
@DB
835835
@Override
836836
public void markPublicIpAsAllocated(final IPAddressVO addr) {
837-
synchronized (_allocatedLock) {
837+
synchronized (allocatedLock) {
838838
Transaction.execute(new TransactionCallbackNoReturn() {
839839
@Override
840840
public void doInTransactionWithoutResult(TransactionStatus status) {
@@ -857,6 +857,8 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
857857
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
858858
}
859859
}
860+
} else {
861+
s_logger.error("Failed to mark public IP as allocated with id=" + addr.getId() + " address=" + addr.getAddress());
860862
}
861863
}
862864
}
@@ -867,14 +869,18 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
867869

868870
@DB
869871
private void markPublicIpAsAllocating(final IPAddressVO addr) {
870-
synchronized (_allocatingLock) {
872+
synchronized (allocatingLock) {
871873
Transaction.execute(new TransactionCallbackNoReturn() {
872874
@Override
873875
public void doInTransactionWithoutResult(TransactionStatus status) {
874876

875877
if (_ipAddressDao.lockRow(addr.getId(), true) != null) {
876878
addr.setState(IpAddress.State.Allocating);
877-
_ipAddressDao.update(addr.getId(), addr);
879+
if (!_ipAddressDao.update(addr.getId(), addr)) {
880+
s_logger.error("Failed to update public IP as allocating with id=" + addr.getId() + " and address=" + addr.getAddress());
881+
}
882+
} else {
883+
s_logger.error("Failed to lock row to mark public IP as allocating with id=" + addr.getId() + " and address=" + addr.getAddress());
878884
}
879885
}
880886
});
@@ -935,8 +941,8 @@ public PublicIp assignDedicateIpAddress(Account owner, final Long guestNtwkId, f
935941
displayIp = vpc.isDisplay();
936942
}
937943

938-
return fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, false, null, false, vpcId, displayIp);
939-
944+
ip = fetchNewPublicIp(dcId, null, null, owner, VlanType.VirtualNetwork, guestNtwkId, isSourceNat, true, null, false, vpcId, displayIp);
945+
return ip;
940946
} finally {
941947
if (owner != null) {
942948
if (s_logger.isDebugEnabled()) {

test/integration/smoke/test_vpc_vpn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ def test_01_vpc_remote_access_vpn(self):
390390
finally:
391391
self.logger.debug("Acquired public ip address: OK")
392392

393+
vpn = None
393394
try:
394395
vpn = Vpn.create(self.apiclient,
395396
publicipid=ip.id,

0 commit comments

Comments
 (0)