From a306aa971b49516222bc3fef6eb84cd3a500a929 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 8 Dec 2025 21:37:17 -0500 Subject: [PATCH] Pick client endpoint as part of the transation --- server/lib/calculateUserClientsForOrgs.ts | 2 +- server/lib/ip.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/lib/calculateUserClientsForOrgs.ts b/server/lib/calculateUserClientsForOrgs.ts index f7666a36..9cdae547 100644 --- a/server/lib/calculateUserClientsForOrgs.ts +++ b/server/lib/calculateUserClientsForOrgs.ts @@ -166,7 +166,7 @@ export async function calculateUserClientsForOrgs( ]; // Get next available subnet - const newSubnet = await getNextAvailableClientSubnet(orgId); + const newSubnet = await getNextAvailableClientSubnet(orgId, transaction); if (!newSubnet) { logger.warn( `Skipping org ${orgId} for OLM ${olm.olmId} (user ${userId}): no available subnet found` diff --git a/server/lib/ip.ts b/server/lib/ip.ts index f9b3cb61..d367a018 100644 --- a/server/lib/ip.ts +++ b/server/lib/ip.ts @@ -244,7 +244,8 @@ export function isIpInCidr(ip: string, cidr: string): boolean { } export async function getNextAvailableClientSubnet( - orgId: string + orgId: string, + transaction: Transaction | typeof db = db ): Promise { const [org] = await db.select().from(orgs).where(eq(orgs.orgId, orgId));