Skip to content

api, daemon: report IPAM status for local-scope networks#50917

Merged
corhere merged 3 commits intomoby:masterfrom
corhere:ipam-allocation-info-localscope
Sep 10, 2025
Merged

api, daemon: report IPAM status for local-scope networks#50917
corhere merged 3 commits intomoby:masterfrom
corhere:ipam-allocation-info-localscope

Conversation

@corhere
Copy link
Contributor

@corhere corhere commented Sep 5, 2025

- What I did
On API v1.52 and newer, the GET /networks/{id} endpoint returns statistics about the IPAM state for the subnets assigned to local-scope networks.

- How I did it
By aggregating the AddrSet popcounts in the default IPAM allocator.

- How to verify it
New integration tests for the bridge, ipvlan and macvlan drivers.

- Human readable description for the release notes

- Inspecting networks with API v1.52 and newer provides statistics about IPAM allocations for the subnets assigned to the network.

- A picture of a cute animal (not mandatory but encouraged)

@corhere corhere added this to the 29.0.0 milestone Sep 5, 2025
@corhere corhere added area/api API kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny labels Sep 5, 2025
@corhere corhere requested a review from tianon as a code owner September 5, 2025 21:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds IPAM allocation status reporting for networks through API v1.52 and newer. This feature provides runtime statistics about IP address usage for local-scope networks to improve network management visibility.

Key changes:

  • Implements IPAM status collection and reporting in the network inspect endpoint
  • Creates iterator utility functions for chaining sequences
  • Refactors uint128 implementation into reusable package
  • Adds comprehensive integration tests

Reviewed Changes

Copilot reviewed 21 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/iterutil/iterutil.go Implements Chain and Chain2 iterator utility functions
internal/iterutil/iterutil_test.go Adds comprehensive tests for iterator utility functions
daemon/libnetwork/network.go Implements IPAMStatus method for network status collection
daemon/libnetwork/ipams/defaultipam/allocator.go Adds PoolStatus method to default IPAM allocator
daemon/libnetwork/ipams/defaultipam/address_space.go Implements allocation status tracking logic
daemon/libnetwork/internal/uint128/uint128.go Refactored uint128 implementation with improved API
daemon/libnetwork/ipbits/ipbits.go Updates to use new uint128 package
api/types/network/* Defines new API types for IPAM status reporting
integration/network/bridge/bridge_linux_test.go Comprehensive integration test for IPAM status feature
daemon/server/router/network/network_routes.go Enables status collection for API v1.52+

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@corhere
Copy link
Contributor Author

corhere commented Sep 5, 2025

I plan to port over the ipvlan and macvlan integration tests from #50450, either in this PR or a fast follow-up. I wanted to get this PR up for review early to give folks a chance to review the proposed API additions while I finish up.

@corhere corhere changed the title api, daemon: report IPAM status for network api, daemon: report IPAM status for local-scope networks Sep 5, 2025
@corhere corhere force-pushed the ipam-allocation-info-localscope branch 3 times, most recently from 267558e to e03bb0d Compare September 8, 2025 20:44
@corhere corhere force-pushed the ipam-allocation-info-localscope branch 3 times, most recently from cba85f7 to f01d0f6 Compare September 9, 2025 17:10
Add utilities to concatenate multiple iterators of the same type into a
single iterator.

Signed-off-by: Cory Snider <csnider@mirantis.com>
The uint128 type is very convenient for manipulating 128 bit-wide
quantities, as tends to come up in several contexts when working with
IPv6. Move it into a libnetwork/internal/ package so it can be reused
elsewhere within libnetwork.

Signed-off-by: Cory Snider <csnider@mirantis.com>
On API v1.52 and newer, the GET /networks/{id} endpoint returns
statistics about the IPAM state for the subnets assigned to the network.

Signed-off-by: Cory Snider <csnider@mirantis.com>
@corhere corhere force-pushed the ipam-allocation-info-localscope branch from f01d0f6 to 3f86797 Compare September 10, 2025 15:06
Copy link
Member

@akerouanton akerouanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@corhere corhere merged commit c463327 into moby:master Sep 10, 2025
179 checks passed
@corhere corhere deleted the ipam-allocation-info-localscope branch September 10, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/networking/ipam Networking impact/api impact/changelog impact/documentation kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny release-blocker PRs we want to block a release on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants