weizhouapache commented on PR #7832:
URL: https://github.com/apache/cloudstack/pull/7832#issuecomment-1675742129

   > > > @winterhazel can you describe what the issue is ?
   > > > I tested 4.18.0.0 without this change. all look good
   > > > ```
   > > > * reserved a IP (IP is Reserved), resource count increases by 1
   > > > 
   > > > * release the IP (IP is Free), resource count decreases by 1
   > > > 
   > > > * reserved a IP again (IP is Reserved), resource count increases by 1
   > > > 
   > > > * associate the IP (IP is Allocated), resource count does not change
   > > > 
   > > > * release the IP (IP is Free), resource count decreases by 1
   > > > ```
   > > 
   > > 
   > > When a user associates a public IP to a guest network through the 
`associateIpAddress` API, the account's resource count is never incremented, 
whether it was a reserved IP or not.
   > > When reserving a public IP through the `reserveIpAddress` API, the 
resource count is being incremented as expected.
   > > > @kiranchavala @winterhazel can you describe the steps to reproduce the 
issue ? I tried both users in ROOT domain and new sub domain
   > > 
   > > 
   > > @kiranchavala described the steps in [this 
comment](https://github.com/apache/cloudstack/pull/7832#pullrequestreview-1571264171).
 You should be able to reproduce it by acquiring multiple `Free` public IPs to 
the guest network through the `associateIpAddress` API.
   > 
   > @winterhazel clear, so the problem is when acquire a public IP, the 
resource limitation check is not performed. the issue is caused by line 1523 
which was added in #6046
   > 
   > ```
   >         ip.setState(State.Allocated);
   > ```
   > 
   > I will review/test next Monday.
   
   @winterhazel 
   my suggestion to fix the issue would be simple like
   ```
   @@ -1510,7 +1510,9 @@ public class IpAddressManagerImpl extends ManagerBase 
implements IpAddressManage
    
            IPAddressVO ip = _ipAddressDao.findById(ipId);
            //update ip address with networkId
   -        ip.setState(State.Allocated);
   +        if (ip.getState() == State.Reserved) {
   +            ip.setState(State.Allocated);
   +        }
            ip.setAssociatedWithNetworkId(networkId);
            ip.setSourceNat(isSourceNat);
            _ipAddressDao.update(ipId, ip);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to