You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ip_version/pool allocation] Refactor IP pool selection to use tagged enums (type-safe API) (#9598)
This PR refactors `FloatingIpCreate`, `EphemeralIpCreate`, `ExternalIpCreate::Ephemeral`, and `ProbeCreate` to use tagged enums for pool selection, making invalid states unrepresentable at the type level.
Previously, these types used flat Option fields (`pool`, `ip_version`, `ip`) that required runtime validation to catch invalid combinations like `ip_version + pool` or `ip + ip_version`. The new design uses:
- `PoolSelector` enum with `Explicit { pool }` and `Auto { ip_version }` variants, used by `EphemeralIpCreate`, `ExternalIpCreate::Ephemeral`, and `ProbeCreate`
- `AddressSelector` enum with `Explicit { ip, pool }` and `Auto { pool_selector }` variants for `FloatingIpCreate`
This all ensures at the type level that...
- `ip_version` can only be specified when auto-selecting from a pool
- `ip_version` cannot be combined with an explicit IP address
- Explicit pools cannot accept `ip_version` (the pool determines available IPs)
Includes:
- The `Explicit { ip, pool }` combination remains valid for reserving a specific IP, validating that it exists in the given pool (pool is a constraint, not a selection method).
- When using `Auto` mode (or when the pool/address selector is omitted), the silo's default pool is used. If the silo has default pools for both IPv4 and IPv6, the request will fail unless `ip_version` is specified to disambiguate.
- API versioning: Added `v2026010300.rs` with the old flat types and `TryFrom` implementations that validate and convert to the new enum-based types for delegation. Older API versions continue to work via the existing conversion chain.
- `ProbeCreate` in the experimental API previously lacked `ip_version` support; this is now addressed using the `PoolSelector` enumerator.
0 commit comments