Skip to content

Add queries to allocate external IPv6 addresses#9282

Merged
bnaecker merged 1 commit into
mainfrom
external-ipv6-address-queries
Nov 3, 2025
Merged

Add queries to allocate external IPv6 addresses#9282
bnaecker merged 1 commit into
mainfrom
external-ipv6-address-queries

Conversation

@bnaecker

@bnaecker bnaecker commented Oct 25, 2025

Copy link
Copy Markdown
Collaborator

@bnaecker bnaecker marked this pull request as draft October 25, 2025 03:18
@bnaecker bnaecker force-pushed the external-ipv6-address-queries branch 3 times, most recently from dc77103 to cdc8461 Compare October 26, 2025 15:37
- Rewrite the `NextExternalIp` query to allow IPv6 address allocations.
  This uses queries more like the existing "next-item" queries based on
  a self-join, where we're joining the existing address with those
  addresses plus-one, and taking the first free one.
- Handle a few more failure-cases from the new query to ensure we detect
  address exhaustion, reallocation, and so on. All the existing tests
  continue to pass.
- Add expectorate / explain "tests" for the new queries
- Add a few new tests, some specifically for IPv6 address allocations
  and the details / corner cases of the new query structure
- Closes #9245
- Closes #1468
- Closes #1371
@bnaecker bnaecker force-pushed the external-ipv6-address-queries branch from cdc8461 to 27cb16e Compare October 27, 2025 16:35
@bnaecker bnaecker marked this pull request as ready for review October 27, 2025 16:35

@rcgoodfellow rcgoodfellow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @bnaecker. To the extent that I'm able to grok the database queries, things seem reasonable to me. The amount of complexity in doing this with SQL makes me wonder if we could do this using client side transactions having more of the logic in Rust to simplify things.

project_id: Some(project_id),
explicit_ip: Some(explicit_ip.into()),
explicit_port_range: None,
explicit_port_range: Some((0, u16::MAX.into())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Based on my reading of where this is used in NextExternalIp::walk_ast the new explicit value and None look like they are equivalent as the former will result in the automatic full ip subquery and the later will result in the explicit ip subquery, but since the latter here contains the entire port space those are equivalent? This seems like it's better in the sense that the function name implies explicit allocation and if automatic allocation changes later this could have a surprising butterfly effect. Just trying to make sure I understand the effect of the change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's right. If we're doing an explicit allocation, we always know both the IP address and ports, so it seems simpler to enforce that at construction time.

@bnaecker

bnaecker commented Nov 3, 2025

Copy link
Copy Markdown
Collaborator Author

Thanks @rcgoodfellow. I agree that an explicit transaction could be simpler in terms of the SQL, but my sense is that we'd pay for that with much more complicated surrounding Rust code. Not the worst tradeoff, but it felt like enough of a wash that I tried to improve the existing query instead.

@bnaecker bnaecker merged commit 7c9c023 into main Nov 3, 2025
16 checks passed
@bnaecker bnaecker deleted the external-ipv6-address-queries branch November 3, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants