-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
ISSUE TYPE
- Bug Report
COMPONENT NAME
GuestNetworkGuru
CLOUDSTACK VERSION
main (4.22)
CONFIGURATION
- Advanced zone
- Network with
SpecifyIpRanges=true - Isolated network type with CIDR (e.g., 10.0.0.0/8 - private address space)
- All IPs in the zone's public pools are already allocated
SUMMARY
GuestNetworkGuru.allocate() incorrectly calls allocateDirectIp() for Isolated networks with SpecifyIpRanges=true. The allocateDirectIp() method is designed for Shared networks only and attempts to allocate IPs from zone-wide VLAN pools. For Isolated networks with SpecifyIpRanges=true, this causes InsufficientAddressCapacityException because Isolated networks should allocate IPs from their own CIDR, not from VLAN pools.
STEPS TO REPRODUCE
- Create an Advanced zone with VLAN ranges configured (e.g., 10.1.1.100-10.1.1.200)
- Create an Isolated network offering with
SpecifyIpRanges=trueand Source NAT service enabled - Create an Isolated network using this offering with CIDR like 10.0.0.0/8
- Deploy a VM in this network when all IPs in the zone's VLAN pools are already allocated
- The VM deployment fails with
InsufficientAddressCapacityException
EXPECTED RESULTS
- For Shared networks with
SpecifyIpRanges=true: IP allocation from VLAN pools usingallocateDirectIp() - For Isolated networks with
SpecifyIpRanges=true: IP allocation from the network's CIDR usingacquireGuestIpAddress()
The correct behavior should be:
- Shared networks → use public IP pool from VLAN ranges
- Isolated networks → use network's own CIDR for IP allocation
ACTUAL RESULTS
GuestNetworkGuru.allocate() at line 445-446:
if (network.getSpecifyIpRanges()) {
_ipAddrMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIPv4(), null);
}This unconditionally calls allocateDirectIp() for ANY network with SpecifyIpRanges=true, regardless of network type.
The stack trace shows:
WARN [c.c.n.IpAddressManagerImpl] Unable to get ip address in zone id=1, network id=295
ERROR [c.c.v.UserVmManagerImpl] error during resource reservation and allocation com.cloud.exception.InsufficientAddressCapacityException: Insufficient address capacityScope=interface com.cloud.dc.DataCenter; id=1
ROOT CAUSE
GuestNetworkGuru.allocate() does not check the network type (getGuestType()) before calling allocateDirectIp(). The method is only valid for Shared networks (GuestType.Shared), but it's being called for Isolated networks as well.
The fix should add a network type check:
if (network.getSpecifyIpRanges()) {
if (network.getGuestType() == GuestType.Shared) {
_ipAddrMgr.allocateDirectIp(nic, dc, vm, network, nic.getRequestedIPv4(), null);
} else {
// For Isolated/L2 networks, use acquireGuestIpAddress() to get IP from network CIDR
}
}FILES AFFECTED
server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java- lines 445-446
ps:
actually I'm not sure for root cause. it's a little complicated