fix(hwlab): route d601 v03 postgres through gateway (#957)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -114,6 +114,7 @@ export function nodeRuntimeRenderOverlay(spec: HwlabRuntimeLaneSpec): Record<str
|
||||
serviceName: spec.externalPostgres.serviceName,
|
||||
endpointAddress: spec.externalPostgres.endpointAddress,
|
||||
port: spec.externalPostgres.port,
|
||||
runtimeAccess: spec.externalPostgres.runtimeAccess ?? null,
|
||||
sslmode: spec.externalPostgres.sslmode,
|
||||
},
|
||||
};
|
||||
@@ -1070,17 +1071,42 @@ export function externalPostgresBridgeStatus(spec: HwlabRuntimeLaneSpec, namespa
|
||||
const pg = spec.externalPostgres;
|
||||
if (pg === undefined) return { required: false, ready: true };
|
||||
if (!namespaceExists) return { required: true, ready: false, degradedReason: "runtime-namespace-missing" };
|
||||
const service = runNodeK3sArgs(spec, ["kubectl", "-n", spec.runtimeNamespace, "get", "service", pg.serviceName, "-o", "name"], 60);
|
||||
const endpointSlice = runNodeK3sArgs(spec, ["kubectl", "-n", spec.runtimeNamespace, "get", "endpointslice", `${pg.serviceName}-host`, "-o", "jsonpath={.endpoints[0].addresses[0]}{\"\\n\"}{.ports[0].port}{\"\\n\"}"], 60);
|
||||
const [address = "", port = ""] = endpointSlice.stdout.split(/\r?\n/u);
|
||||
const runtimeAccess = pg.runtimeAccess ?? { endpointAddress: pg.endpointAddress, port: pg.port };
|
||||
const endpointIsIpv4 = /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/u.test(runtimeAccess.endpointAddress);
|
||||
const service = runNodeK3sArgs(spec, ["kubectl", "-n", spec.runtimeNamespace, "get", "service", pg.serviceName, "-o", "jsonpath={.spec.type}{\"\\n\"}{.spec.externalName}{\"\\n\"}{.spec.ports[0].port}{\"\\n\"}"], 60);
|
||||
const [serviceType = "", externalName = "", servicePort = ""] = service.stdout.split(/\r?\n/u);
|
||||
if (!endpointIsIpv4) {
|
||||
const ready = service.exitCode === 0 && serviceType === "ExternalName" && externalName === runtimeAccess.endpointAddress && Number(servicePort) === runtimeAccess.port;
|
||||
return {
|
||||
required: true,
|
||||
ready,
|
||||
serviceName: pg.serviceName,
|
||||
serviceType: serviceType || null,
|
||||
externalName: externalName || null,
|
||||
expectedExternalName: runtimeAccess.endpointAddress,
|
||||
port: numericField(servicePort),
|
||||
expectedPort: runtimeAccess.port,
|
||||
providerEndpointAddress: pg.endpointAddress,
|
||||
providerPort: pg.port,
|
||||
runtimeAccess: pg.runtimeAccess ?? null,
|
||||
service: compactRuntimeCommand(service),
|
||||
};
|
||||
}
|
||||
const endpointSlice = runNodeK3sArgs(spec, ["kubectl", "-n", spec.runtimeNamespace, "get", "endpointslice", `${pg.serviceName}-host`, "-o", "jsonpath={.addressType}{\"\\n\"}{.endpoints[0].addresses[0]}{\"\\n\"}{.ports[0].port}{\"\\n\"}"], 60);
|
||||
const [addressType = "", address = "", port = ""] = endpointSlice.stdout.split(/\r?\n/u);
|
||||
return {
|
||||
required: true,
|
||||
ready: service.exitCode === 0 && endpointSlice.exitCode === 0 && address === pg.endpointAddress && Number(port) === pg.port,
|
||||
ready: service.exitCode === 0 && endpointSlice.exitCode === 0 && serviceType !== "ExternalName" && address === runtimeAccess.endpointAddress && Number(port) === runtimeAccess.port,
|
||||
serviceName: pg.serviceName,
|
||||
serviceType: serviceType || null,
|
||||
addressType: addressType || null,
|
||||
endpointAddress: address || null,
|
||||
expectedEndpointAddress: pg.endpointAddress,
|
||||
expectedEndpointAddress: runtimeAccess.endpointAddress,
|
||||
port: numericField(port),
|
||||
expectedPort: pg.port,
|
||||
expectedPort: runtimeAccess.port,
|
||||
providerEndpointAddress: pg.endpointAddress,
|
||||
providerPort: pg.port,
|
||||
runtimeAccess: pg.runtimeAccess ?? null,
|
||||
service: compactRuntimeCommand(service),
|
||||
endpointSlice: compactRuntimeCommand(endpointSlice),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user