Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: address PR review feedback

bernie-g7eb7f073ed46
diff --git a/backend/src/ee/services/gateway-pool/gateway-pool-dal.ts b/backend/src/ee/services/gateway-pool/gateway-pool-dal.ts
index 118b294293..33c0e2f4b9 100644
--- a/backend/src/ee/services/gateway-pool/gateway-pool-dal.ts
+++ b/backend/src/ee/services/gateway-pool/gateway-pool-dal.ts
@@ -35,6 +35,9 @@ export const gatewayPoolDalFactory = (db: TDbClient) => {
),
db.raw(
`COALESCE(array_agg(DISTINCT ${TableName.GatewayPoolMembership}."gatewayId") FILTER (WHERE ${TableName.GatewayPoolMembership}."gatewayId" IS NOT NULL), '{}') AS "memberGatewayIds"`
+ ),
+ db.raw(
+ `(SELECT COUNT(*) FROM ${TableName.IdentityKubernetesAuth} WHERE ${TableName.IdentityKubernetesAuth}."gatewayPoolId" = ${TableName.GatewayPool}.id) AS "connectedResourcesCount"`
)
)
.groupBy(`${TableName.GatewayPool}.id`)
@@ -46,7 +49,8 @@ export const gatewayPoolDalFactory = (db: TDbClient) => {
...p,
memberCount: Number(raw.memberCount ?? 0),
healthyMemberCount: Number(raw.healthyMemberCount ?? 0),
- memberGatewayIds: (raw.memberGatewayIds as string[]) ?? []
+ memberGatewayIds: (raw.memberGatewayIds as string[]) ?? [],
+ connectedResourcesCount: Number(raw.connectedResourcesCount ?? 0)
};
});
} catch (error) {
diff --git a/backend/src/ee/services/gateway-pool/gateway-pool-service.ts b/backend/src/ee/services/gateway-pool/gateway-pool-service.ts
index 7d2ce85c12..386a136893 100644
--- a/backend/src/ee/services/gateway-pool/gateway-pool-service.ts
+++ b/backend/src/ee/services/gateway-pool/gateway-pool-service.ts
@@ -95,17 +95,7 @@ export const gatewayPoolServiceFactory = ({
await $checkPermission(actor, OrgPermissionGatewayPoolActions.ListGatewayPools);
await $checkLicense(actor.orgId);
- const pools = await gatewayPoolDAL.findByOrgIdWithDetails(actor.orgId);
-
- const poolsWithCounts = await Promise.all(
- pools.map(async (pool) => {
- // Add more DAL counts here as pool support expands to other consumers
- const k8sCount = await identityKubernetesAuthDAL.countByGatewayPoolId(pool.id);
- return { ...pool, connectedResourcesCount: k8sCount };
- })
- );
-
- return poolsWithCounts;
+ return gatewayPoolDAL.findByOrgIdWithDetails(actor.orgId);
};
const getGatewayPoolById = async ({ poolId, ...actor }: TGetGatewayPoolByIdDTO) => {
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.ts
index de08aecbc2..a640b1ddde 100644
--- a/backend/src/keystore/keystore.ts
+++ b/backend/src/keystore/keystore.ts
@@ -32,7 +32,6 @@ export const PgSqlLock = {
PamResourceSshCaInit: (resourceId: string) => pgAdvisoryLockHashText(`pam-resource-ssh-ca-init:${resourceId}`),
CreateIdentity: (orgId: string) => pgAdvisoryLockHashText(`create-identity:${orgId}`),
CreateGateway: (orgId: string) => pgAdvisoryLockHashText(`create-gateway:${orgId}`),
- CreateGatewayPool: (orgId: string) => pgAdvisoryLockHashText(`create-gateway-pool:${orgId}`),
AccessSharedSecret: (sharedSecretId: string) => pgAdvisoryLockHashText(`access-shared-secret:${sharedSecretId}`),
KmsOrgKeyCreation: (orgId: string) => pgAdvisoryLockHashText(`kms-org-key:${orgId}`),
KmsOrgDataKeyCreation: (orgId: string) => pgAdvisoryLockHashText(`kms-org-data-key:${orgId}`),
diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
index 4ffa4cadce..6b658c7651 100644
--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts
@@ -1141,7 +1141,7 @@ export const identityKubernetesAuthServiceFactory = ({
gatewayV2IdValue = gatewayId;
}
}
- const gatewayPoolIdValue = gatewayPoolId ?? (gatewayId !== undefined ? null : undefined);
+ const gatewayPoolIdValue = gatewayPoolId !== undefined ? gatewayPoolId : (gatewayId !== undefined ? null : undefined);
const effectiveTokenReviewMode = tokenReviewMode ?? identityKubernetesAuth.tokenReviewMode;
const effectiveKubernetesHost =
@@ -1179,7 +1179,10 @@ export const identityKubernetesAuthServiceFactory = ({
const picked = await gatewayPoolService.pickRandomHealthyGateway(effectiveGatewayPoolId);
validationGatewayId = picked.id;
} catch {
- // No healthy gateways in pool, skip validation
+ logger.warn(
+ { gatewayPoolId: effectiveGatewayPoolId },
+ "No healthy gateways in pool, skipping connectivity validation for k8s auth update"
+ );
}
}
diff --git a/frontend/src/hooks/api/identities/mutations.tsx b/frontend/src/hooks/api/identities/mutations.tsx
index f815823da2..9f2163c4da 100644
--- a/frontend/src/hooks/api/identities/mutations.tsx
+++ b/frontend/src/hooks/api/identities/mutations.tsx
@@ -1539,7 +1539,6 @@ export const useDeleteIdentityAzureAuth = () => {
}
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityById(identityId) });
queryClient.invalidateQueries({ queryKey: identitiesKeys.getIdentityAzureAuth(identityId) });
- queryClient.invalidateQueries({ queryKey: gatewayPoolsKeys.allKey() });
}
});
};
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx
index d425a75a72..d4f3d5607c 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx
@@ -208,14 +208,14 @@ export const PoolDetailSheet = ({ isOpen, onOpenChange, pool }: Props) => {
</UnstableTableRow>
)}
{memberGateways.map((gw) => {
- const isHealthy =
- "lastHealthCheckStatus" in gw &&
- gw.lastHealthCheckStatus === GatewayHealthCheckStatus.Healthy;
const hasHeartbeat =
"heartbeat" in gw &&
gw.heartbeat &&
new Date(gw.heartbeat).getTime() > Date.now() - 60 * 60 * 1000;
- const isOnline = hasHeartbeat && isHealthy;
+ const isNotFailed =
+ !("lastHealthCheckStatus" in gw) ||
+ gw.lastHealthCheckStatus !== GatewayHealthCheckStatus.Failed;
+ const isOnline = hasHeartbeat && isNotFailed;
return (
<UnstableTableRow key={gw.id}>