-
Notifications
You must be signed in to change notification settings - Fork 62
Description
In #3985, IP pools gained an explicit property is_default, which can be set at create time. However, it cannot be changed through the IP pool update endpoint.
omicron/nexus/types/src/external_api/params.rs
Lines 729 to 752 in 01e730a
| /// Create-time parameters for an `IpPool` | |
| #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] | |
| pub struct IpPoolCreate { | |
| #[serde(flatten)] | |
| pub identity: IdentityMetadataCreateParams, | |
| /// If an IP pool is associated with a silo, instance IP allocations in that | |
| /// silo can draw from that pool. | |
| pub silo: Option<NameOrId>, | |
| /// Whether the IP pool is considered a default pool for its scope (fleet, | |
| /// or silo). If a pool is marked default and is associated with a silo, | |
| /// instances created in that silo will draw IPs from that pool unless | |
| /// another pool is specified at instance create time. | |
| #[serde(default)] | |
| pub is_default: bool, | |
| } | |
| /// Parameters for updating an IP Pool | |
| #[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)] | |
| pub struct IpPoolUpdate { | |
| #[serde(flatten)] | |
| pub identity: IdentityMetadataUpdateParams, | |
| } |
Because there can be at most one default for a given scope (fleet-wide or silo-specific),
omicron/schema/crdb/dbinit.sql
Lines 1497 to 1505 in 01e730a
| /* | |
| * Ensure there can only be one default pool for the fleet or a given silo. | |
| * Coalesce is needed because otherwise different nulls are considered to be | |
| * distinct from each other. | |
| */ | |
| CREATE UNIQUE INDEX IF NOT EXISTS one_default_pool_per_scope ON omicron.public.ip_pool ( | |
| COALESCE(silo_id, '00000000-0000-0000-0000-000000000000'::uuid) | |
| ) WHERE | |
| is_default = true AND time_deleted IS NULL; |
Proposal
I don't think it makes sense to add is_default to the update params. Instead, I think we should have a make default endpoint, sort of analogous to image promotion and demotion. This endpoint would
- set
is_default = falseon the current default pool (if there is one) - set
is_default = trueon the target pool
We probably also want a make-not-default endpoint, but it should probably only work on silo-scoped pools, otherwise instance create could fail due to there being no default pool.