Skip to content

network: name the network whose IP ranges are full, return a capacity error on deploy - #14958

Open
rootnomad wants to merge 3 commits into
apache:mainfrom
rootnomad:fix/ip-range-full-capacity-error
Open

rootnomad wants to merge 3 commits into
apache:mainfrom
rootnomad:fix/ip-range-full-capacity-error

Conversation

@rootnomad

Copy link
Copy Markdown
Collaborator

Description

A network with its own IP ranges (shared, or isolated with SpecifyIpRanges) gives guest VMs IPs only from those ranges. When the ranges were full, deploying a VM failed as an internal error (530) with just "Insufficient address capacity", scoped to the zone, and the management server logged a stack trace at ERROR. That reads like the zone ran out of public IPs, which is what #12772 ran into.

This names the network in that error, or the requested IP when a specific one was asked for and is already taken. It also lets the capacity exception through the resource reservation wrapper in deploy, so the API returns INSUFFICIENT_CAPACITY_ERROR (533) with that message instead of an internal error. The exception scope stays on the zone, so the deployment retry logic is unchanged.

#14087 tried to fix this by making isolated networks with SpecifyIpRanges allocate from the whole CIDR. As @Damans227 pointed out there, that ignores the start and end IP set on the network. This keeps allocation on the network's IP ranges, with a test for it, and fixes the error instead.

Fixes: #12772

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

N/A

How Has This Been Tested?

Unit tests for the new messages and for GuestNetworkGuru.allocate() on isolated and shared networks with SpecifyIpRanges. The isolated allocate test fails with the change from #14087 (allocateDirectIp is never called) and passes here.

Live on a KVM advanced zone with a management server and 2 hosts: an isolated network with SpecifyIpRanges and a 3 address range, and a shared network with a 2 address range. Filled each range with VMs, then deployed one more, and deployed one asking for an IP that was already taken. In both runs the VMs only got IPs from the network ranges.

Before:

isolated, range full    530  Insufficient address capacity
shared, range full      530  Insufficient address capacity
requested IP in use     530  Insufficient address capacity
an ERROR stack trace "error during resource reservation and allocation" for each

After:

isolated, range full    533  Insufficient address capacity: no free IP address left in the IP ranges of network specifyip-iso-net
shared, range full      533  Insufficient address capacity: no free IP address left in the IP ranges of network specifyip-shared-net
requested IP in use     533  Insufficient address capacity: the requested IP address <ip> is not available in the IP ranges of network specifyip-iso-net
no ERROR stack traces

How did you try to break this feature and the system with this change?

Checked the other callers that create VMs through the same path (autoscale, Kubernetes clusters, Veeam restore). They already catch InsufficientCapacityException next to CloudRuntimeException, so their handling does not change. Public IP and system VM allocation keep the old message.

A network with its own IP ranges (shared, or isolated with SpecifyIpRanges)
allocates guest IPs only from those ranges. When they are all in use the
allocation failed with a bare "Insufficient address capacity" scoped to the
zone, which reads as the zone running out of public IPs. Say which network
ran out, or that the requested IP is not available in it. The scope stays
on the zone so the deployment retry logic is unchanged.
The resource reservation wrapper in deployVirtualMachine caught every
exception other than ResourceAllocationException and CloudRuntimeException,
logged it at ERROR with a stack trace and rethrew it as a CloudRuntimeException.
An InsufficientCapacityException from NIC allocation therefore reached the
API as an internal error with the raw exception text. Let it through so
DeployVMCmd returns INSUFFICIENT_CAPACITY_ERROR with the exception message.
…ranges

Cover GuestNetworkGuru.allocate() for isolated and shared networks with
SpecifyIpRanges: both take the address from the network's IP ranges through
allocateDirectIp, not from the whole CIDR.
@rootnomad rootnomad changed the title Fix/ip range full capacity error network: name the network whose IP ranges are full, return a capacity error on deploy Dec 2, 2026
@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.33333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.17%. Comparing base (974c27b) to head (2a39afb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 4 Missing ⚠️
...n/java/com/cloud/network/IpAddressManagerImpl.java 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              main   #14958       +/-   ##
============================================
+ Coverage     3.87%   21.17%   +17.30%     
- Complexity       0    21577    +21577     
============================================
  Files          499     6080     +5581     
  Lines        43120   551780   +508660     
  Branches      8198    73936    +65738     
============================================
+ Hits          1670   116847   +115177     
- Misses       41215   421140   +379925     
- Partials       235    13793    +13558     
Flag Coverage Δ
uitests 3.87% <ø> (ø)
unittests 22.64% <58.33%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: GuestNetworkGuru.allocate() incorrectly calls allocateDirectIp() for Isolated networks with SpecifyIpRanges=true

1 participant