mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-19 10:42:57 +02:00
Deduplicate inference resources by fullDomain to prevent duplicate routers
This commit is contained in:
@@ -598,19 +598,31 @@ export async function getTraefikConfig(
|
|||||||
// plain http-mode resources, but the service points at the AI
|
// plain http-mode resources, but the service points at the AI
|
||||||
// gateway instead of any real backend targets.
|
// gateway instead of any real backend targets.
|
||||||
//
|
//
|
||||||
// A siteResource inference alias can share the exact same fullDomain
|
// Inference-mode resources are allowed to share a fullDomain with
|
||||||
// as one of these (both ultimately proxy to the same aiGatewayUrl),
|
// each other (see createResource.ts), and a siteResource inference
|
||||||
// so track which domains get a public router here and skip creating
|
// alias can share that domain too - all of them proxy to the same
|
||||||
// a second, duplicate router for the siteResource alias below.
|
// aiGatewayUrl, so dedupe by fullDomain here (lowest resourceId
|
||||||
const publicInferenceDomains = new Set<string>();
|
// wins, for stable output across regenerations) and skip the
|
||||||
for (const ir of inferenceResources) {
|
// siteResource alias router for any domain already covered below.
|
||||||
if (!ir.enabled) continue;
|
const eligibleInferenceResources = inferenceResources
|
||||||
if (!ir.domainId || !ir.fullDomain) continue;
|
.filter((ir) => ir.enabled && ir.domainId && ir.fullDomain)
|
||||||
|
.sort((a, b) => a.resourceId - b.resourceId);
|
||||||
|
const dedupedInferenceResources = new Map<
|
||||||
|
string,
|
||||||
|
(typeof eligibleInferenceResources)[number]
|
||||||
|
>();
|
||||||
|
for (const ir of eligibleInferenceResources) {
|
||||||
|
if (!dedupedInferenceResources.has(ir.fullDomain!)) {
|
||||||
|
dedupedInferenceResources.set(ir.fullDomain!, ir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const publicInferenceDomains = new Set<string>();
|
||||||
|
for (const ir of dedupedInferenceResources.values()) {
|
||||||
if (!config_output.http.routers) config_output.http.routers = {};
|
if (!config_output.http.routers) config_output.http.routers = {};
|
||||||
if (!config_output.http.services) config_output.http.services = {};
|
if (!config_output.http.services) config_output.http.services = {};
|
||||||
|
|
||||||
const fullDomain = ir.fullDomain;
|
const fullDomain = ir.fullDomain!;
|
||||||
const irKey = `inference-r${ir.resourceId}`;
|
const irKey = `inference-r${ir.resourceId}`;
|
||||||
const routerName = `${irKey}-router`;
|
const routerName = `${irKey}-router`;
|
||||||
const serviceName = `${irKey}-service`;
|
const serviceName = `${irKey}-service`;
|
||||||
|
|||||||
@@ -893,19 +893,31 @@ export async function getTraefikConfig(
|
|||||||
// plain http-mode resources, but the service points at the AI
|
// plain http-mode resources, but the service points at the AI
|
||||||
// gateway instead of any real backend targets.
|
// gateway instead of any real backend targets.
|
||||||
//
|
//
|
||||||
// A siteResource inference alias can share the exact same fullDomain
|
// Inference-mode resources are allowed to share a fullDomain with
|
||||||
// as one of these (both ultimately proxy to the same aiGatewayUrl),
|
// each other (see createResource.ts), and a siteResource inference
|
||||||
// so track which domains get a public router here and skip creating
|
// alias can share that domain too - all of them proxy to the same
|
||||||
// a second, duplicate router for the siteResource alias below.
|
// aiGatewayUrl, so dedupe by fullDomain here (lowest resourceId
|
||||||
const publicInferenceDomains = new Set<string>();
|
// wins, for stable output across regenerations) and skip the
|
||||||
for (const ir of inferenceResources) {
|
// siteResource alias router for any domain already covered below.
|
||||||
if (!ir.enabled) continue;
|
const eligibleInferenceResources = inferenceResources
|
||||||
if (!ir.domainId || !ir.fullDomain) continue;
|
.filter((ir) => ir.enabled && ir.domainId && ir.fullDomain)
|
||||||
|
.sort((a, b) => a.resourceId - b.resourceId);
|
||||||
|
const dedupedInferenceResources = new Map<
|
||||||
|
string,
|
||||||
|
(typeof eligibleInferenceResources)[number]
|
||||||
|
>();
|
||||||
|
for (const ir of eligibleInferenceResources) {
|
||||||
|
if (!dedupedInferenceResources.has(ir.fullDomain!)) {
|
||||||
|
dedupedInferenceResources.set(ir.fullDomain!, ir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const publicInferenceDomains = new Set<string>();
|
||||||
|
for (const ir of dedupedInferenceResources.values()) {
|
||||||
if (!config_output.http.routers) config_output.http.routers = {};
|
if (!config_output.http.routers) config_output.http.routers = {};
|
||||||
if (!config_output.http.services) config_output.http.services = {};
|
if (!config_output.http.services) config_output.http.services = {};
|
||||||
|
|
||||||
const fullDomain = ir.fullDomain;
|
const fullDomain = ir.fullDomain!;
|
||||||
const irKey = `inference-r${ir.resourceId}`;
|
const irKey = `inference-r${ir.resourceId}`;
|
||||||
const routerName = `${irKey}-router`;
|
const routerName = `${irKey}-router`;
|
||||||
const serviceName = `${irKey}-service`;
|
const serviceName = `${irKey}-service`;
|
||||||
|
|||||||
Reference in New Issue
Block a user