CLOUDSTACK-9694: Unable to limit the Public IPs in VPC #1850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unable to limit the Public IPs in VPC.
In VPC network, while acquiring the IP addresses, in the resource_count table, count for the domain is getting increased. However, when the resource count is updated at Domain level, resource count is getting reverted to only non-vpc ip count.
Steps to Reproduce:
Root Cause: Update resource count command recalculates the resource count. While computing public IP we are not considering the ips allocated to VPC.
ResourceLimitManagerImpl.java -> calculatePublicIpForAccount() -> IPAddressDaoImpl.countAllocatedIPsForAccount()
Currently we have below query builder. Which does not consider vpc_id column.
it generates below sql query
Fix:
Add vpc_id check in query.
SQL:
Test Result:
Initial resource count
Aquire 2 more public ip in VPC network.
After updating resource count at for doamin 3.
Output of INCORRECT query used for calculating public ip addresses.
Output of CORRECT query used for calculating public ip addresses.
After FIX: