Open
Conversation
Implement the subnet_pool_utilization_view endpoint, which was previously a stub returning 500. The implementation follows the IP pool utilization pattern: fetch subnet CIDRs from the database, compute sizes in Rust using u128 arithmetic, and return remaining/capacity as f64. Changes: - Add a new API version (SUBNET_POOL_UTILIZATION_REMAINING) that changes SubnetPoolUtilization from allocated/capacity to remaining/capacity, matching IpPoolUtilization. - Add datastore methods: subnet_pool_utilization, helpers for fetching member and external subnet CIDRs, and accumulate_subnet_sizes. - Wire up the app layer to call the datastore and compute remaining. - Add datastore unit tests for IPv4 and IPv6 pools. - Add integration tests via assert_subnet_pool_utilization helper. - Update verify_endpoints from GetUnimplemented to Get.
b699fb4 to
4e58295
Compare
david-crespo
commented
Mar 26, 2026
| } | ||
| Ok(count) | ||
| } | ||
|
|
Contributor
Author
There was a problem hiding this comment.
Compare to IP pool utilization:
omicron/nexus/db-queries/src/db/datastore/ip_pool.rs
Lines 864 to 986 in b2d7cde
david-crespo
commented
Mar 26, 2026
| fn from(new: SubnetPoolUtilization) -> Self { | ||
| Self { allocated: new.capacity - new.remaining, capacity: new.capacity } | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This is silly and I think loses precision, but the endpoint was unimplemented, so there can't be anyone who is relying on the current version.
david-crespo
commented
Mar 26, 2026
| let capacity = (1u128 << 80) as f64; | ||
| assert_subnet_pool_utilization(client, SUBNET_POOL_NAME, 0.0, capacity) | ||
| .await; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
compare to
omicron/nexus/tests/integration_tests/ip_pools.rs
Lines 939 to 1026 in b2d7cde
david-crespo
commented
Mar 26, 2026
|
|
||
| db.terminate().await; | ||
| logctx.cleanup_successful(); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
compare to
omicron/nexus/db-queries/src/db/datastore/ip_pool.rs
Lines 2784 to 3039 in b2d7cde
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #10109
Follows the same pattern as IP pool utilization. Counting addresses feels a little weird, since subnets are blocks of addresses, but there isn't really another unit we can use.
accumulate_subnet_sizessums subnet sizes using checked 128-bit arithmetic, analogous toaccumulate_ip_range_sizes.remaining = capacity - allocatedin u128 before converting to f64, matchingip_pool_utilization_view.{ remaining, capacity }(both f64), matchingIpPoolUtilization.