Skip to content

Commit cea14ce

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-4573: fixed resource limit check when acquire public IP in VPC - update resource count for VPC public ip even when network_id is not set yet.
1 parent a14145b commit cea14ce

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public void markPublicIpAsAllocated(IPAddressVO addr) {
551551
addr.getSystem(), addr.getClass().getName(), addr.getUuid());
552552
}
553553
// don't increment resource count for direct and dedicated ip addresses
554-
if (addr.getAssociatedWithNetworkId() != null && !isIpDedicated(addr)) {
554+
if (updateIpResourceCount(addr)) {
555555
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.public_ip);
556556
}
557557
}
@@ -3783,7 +3783,7 @@ public IPAddressVO markIpAsUnavailable(long addrId) {
37833783
txn.start();
37843784

37853785
// don't decrement resource count for direct and dedicated ips
3786-
if (ip.getAssociatedWithNetworkId() != null && !isIpDedicated(ip)) {
3786+
if (updateIpResourceCount(ip)) {
37873787
_resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip);
37883788
}
37893789

@@ -3807,7 +3807,10 @@ public IPAddressVO markIpAsUnavailable(long addrId) {
38073807

38083808
return ip;
38093809
}
3810-
3810+
3811+
protected boolean updateIpResourceCount(IPAddressVO ip) {
3812+
return (ip.getAssociatedWithNetworkId() != null || ip.getVpcId() != null) && !isIpDedicated(ip);
3813+
}
38113814

38123815

38133816
Random _rand = new Random(System.currentTimeMillis());

0 commit comments

Comments
 (0)