From 712bf39c8d2e1133a9b26930e38258565fcb0a4b Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Mon, 20 Apr 2026 17:58:53 +0200 Subject: [PATCH 1/3] don't always use default silo when selecting default pool --- mock-api/msw/db.ts | 7 ++++--- mock-api/msw/handlers.ts | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mock-api/msw/db.ts b/mock-api/msw/db.ts index 0c1533f91..9f789da0e 100644 --- a/mock-api/msw/db.ts +++ b/mock-api/msw/db.ts @@ -68,14 +68,15 @@ export const resolvePoolSelector = ( | { pool: string; type: 'explicit' } | { type: 'auto'; ip_version?: IpVersion | null } | undefined, - poolType?: IpPoolType + poolType?: IpPoolType, + siloId: string = defaultSilo.id ) => { if (poolSelector?.type === 'explicit') { return lookup.ipPool({ pool: poolSelector.pool }) } // For 'auto' type, find the default pool for the specified IP version and pool type - const silo = lookup.silo({ silo: defaultSilo.id }) + const silo = lookup.silo({ silo: siloId }) const links = db.ipPoolSilos.filter((ips) => ips.silo_id === silo.id && ips.is_default) // Filter candidate pools by both IP version and pool type @@ -108,7 +109,7 @@ export const resolvePoolSelector = ( if (!link) { const typeStr = poolType ? ` ${poolType}` : '' const versionStr = poolSelector?.ip_version ? ` ${poolSelector.ip_version}` : '' - throw notFoundErr(`default${typeStr}${versionStr} pool for silo '${defaultSilo.id}'`) + throw notFoundErr(`default${typeStr}${versionStr} pool for silo '${siloId}'`) } return lookupById(db.ipPools, link.ip_pool_id) } diff --git a/mock-api/msw/handlers.ts b/mock-api/msw/handlers.ts index cbda97ede..ac172e71e 100644 --- a/mock-api/msw/handlers.ts +++ b/mock-api/msw/handlers.ts @@ -395,10 +395,10 @@ export const handlers = makeHandlers({ return true // For mock purposes, just use first unicast pool }) }) - pool = poolWithIp || resolvePoolSelector(undefined, 'unicast') + pool = poolWithIp || resolvePoolSelector(undefined, 'unicast', project.silo_id) } else { // type === 'auto' - pool = resolvePoolSelector(addressAllocator.pool_selector, 'unicast') + pool = resolvePoolSelector(addressAllocator.pool_selector, 'unicast', project.silo_id) ip = getIpFromPool(pool) } @@ -640,7 +640,7 @@ export const handlers = makeHandlers({ // which aren't quite as good as checking that there are actually IPs // available, but they are good things to check // Ephemeral IPs must use unicast pools - const pool = resolvePoolSelector(ip.pool_selector, 'unicast') + const pool = resolvePoolSelector(ip.pool_selector, 'unicast', project.silo_id) getIpFromPool(pool) // Validate that external IP version matches NIC's IP stack @@ -773,7 +773,7 @@ export const handlers = makeHandlers({ floatingIp.instance_id = instanceId } else if (ip.type === 'ephemeral') { // Ephemeral IPs must use unicast pools - const pool = resolvePoolSelector(ip.pool_selector, 'unicast') + const pool = resolvePoolSelector(ip.pool_selector, 'unicast', project.silo_id) const firstAvailableAddress = getIpFromPool(pool) db.ephemeralIps.push({ @@ -959,8 +959,9 @@ export const handlers = makeHandlers({ }, instanceEphemeralIpAttach({ path, query: projectParams, body }) { const instance = lookup.instance({ ...path, ...projectParams }) + const instanceProject = lookup.project(projectParams) // Ephemeral IPs must use unicast pools - const pool = resolvePoolSelector(body.pool_selector, 'unicast') + const pool = resolvePoolSelector(body.pool_selector, 'unicast', instanceProject.silo_id) const ip = getIpFromPool(pool) // Validate that external IP version matches primary NIC's IP stack From 350c3e454371b5140b68895ff31fca003b278952 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Mon, 20 Apr 2026 20:20:16 +0200 Subject: [PATCH 2/3] make poolType param required --- mock-api/msw/db.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mock-api/msw/db.ts b/mock-api/msw/db.ts index 9f789da0e..04c037742 100644 --- a/mock-api/msw/db.ts +++ b/mock-api/msw/db.ts @@ -68,7 +68,7 @@ export const resolvePoolSelector = ( | { pool: string; type: 'explicit' } | { type: 'auto'; ip_version?: IpVersion | null } | undefined, - poolType?: IpPoolType, + poolType: IpPoolType, siloId: string = defaultSilo.id ) => { if (poolSelector?.type === 'explicit') { @@ -84,8 +84,7 @@ export const resolvePoolSelector = ( const pool = db.ipPools.find((p) => p.id === ips.ip_pool_id) if (!pool) return false - // If poolType specified, filter by it - if (poolType && pool.pool_type !== poolType) return false + if (pool.pool_type !== poolType) return false // If IP version specified, filter by it if (poolSelector?.ip_version && pool.ip_version !== poolSelector.ip_version) { From f5da86cd10c5847af5c30ad84648ebdaa779b7ea Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Mon, 20 Apr 2026 20:39:08 +0200 Subject: [PATCH 3/3] small refactor thanks to required param --- mock-api/msw/db.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mock-api/msw/db.ts b/mock-api/msw/db.ts index 04c037742..c6a08f619 100644 --- a/mock-api/msw/db.ts +++ b/mock-api/msw/db.ts @@ -106,9 +106,8 @@ export const resolvePoolSelector = ( const link = candidateLinks[0] if (!link) { - const typeStr = poolType ? ` ${poolType}` : '' const versionStr = poolSelector?.ip_version ? ` ${poolSelector.ip_version}` : '' - throw notFoundErr(`default${typeStr}${versionStr} pool for silo '${siloId}'`) + throw notFoundErr(`default ${poolType}${versionStr} pool for silo '${siloId}'`) } return lookupById(db.ipPools, link.ip_pool_id) }