Skip to content

fix: properly allocate adjacent single address external subnets#10747

Open
sudomateo wants to merge 2 commits into
mainfrom
sudomateo/tmpxkzpouvwn
Open

fix: properly allocate adjacent single address external subnets#10747
sudomateo wants to merge 2 commits into
mainfrom
sudomateo/tmpxkzpouvwn

Conversation

@sudomateo

@sudomateo sudomateo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Updated the database logic to properly allow allocation of adjacent single address external subnets (e.g., /32, /128).

Closes #10748.

Added a regression test that shows subnet pools fail to allocate
adjacent single address subnets (e.g., /32, /128).
@sudomateo sudomateo force-pushed the sudomateo/tmpxkzpouvwn branch from bc26e9f to 2a80381 Compare July 6, 2026 00:52
@sudomateo sudomateo linked an issue Jul 6, 2026 that may be closed by this pull request
@sudomateo

Copy link
Copy Markdown
Contributor Author

I'll continue this tomorrow. Just wanted to get this test pushed to show that the current code is broken in this case.

Updated the database logic to properly allow allocation of adjacent
single address external subnets (e.g., /32, /128).

Closes #10748.
@sudomateo sudomateo changed the title nexus: regression test for adjacent single address subnet pools fix: properly allocate adjacent single address external subnets Jul 6, 2026
Comment on lines +1302 to +1317
// Unique index names from `dbinit.sql`. CockroachDB reports these as the
// constraint name on a unique violation, allowing us to match against them for
// better error messaging.

/// Uniqueness of (`project_id`, `name`).
const EXTERNAL_SUBNET_NAME_CONSTRAINT: &str =
"external_subnet_project_id_name_key";

/// Uniqueness of (`subnet`).
const EXTERNAL_SUBNET_SUBNET_CONSTRAINT: &str =
"lookup_external_subnet_by_subnet";

/// Uniqueness of (`first_address`, `last_address`).
const EXTERNAL_SUBNET_ADDRESS_CONSTRAINT: &str =
"lookup_external_subnet_by_first_and_last_address";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't love that these constants can get out of sync with what's in dbinit.sql but I didn't know how to tie them together. I do like the better error messaging they provide though.

@sudomateo sudomateo marked this pull request as ready for review July 6, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot allocate adjacent single address external subnets

1 participant