Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib/onboard/gateway-host-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,17 @@ describe("gateway host runtime attachment probe", () => {

it("reads the authoritative gateway port lazily, not at construction (#6576)", () => {
let port = 8080;
const runtime = createGatewayHostRuntime(createDeps({ gatewayPort: () => port }));
const getGatewayStartNetworkEnv = vi.fn((gatewayPort: number) => ({
OPENSHELL_SERVER_PORT: String(gatewayPort),
}));
const runtime = createGatewayHostRuntime(
createDeps({ gatewayPort: () => port, getGatewayStartNetworkEnv }),
);

port = 9443;

expect(runtime.getGatewayStartEnv()).toMatchObject({ OPENSHELL_SERVER_PORT: "9443" });
expect(getGatewayStartNetworkEnv).toHaveBeenCalledWith(9443);
}, 15_000);

it("registers and selects the exact declared endpoint without prior gateway metadata (#6576)", async () => {
Expand Down
11 changes: 8 additions & 3 deletions src/lib/onboard/gateway-host-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface GatewayHostRuntimeDeps {
*/
gatewayPort(): number;
gatewayName(): string;
/** Optional narrow resolver for callers that already own the gateway network boundary. */
getGatewayStartNetworkEnv?(gatewayPort: number): Record<string, string>;
/**
* Unfiltered listener enumeration. An externally supervised gateway is an
* ordinary systemd-run executable with no Docker-driver env markers, so the
Expand Down Expand Up @@ -545,9 +547,12 @@ export function createGatewayHostRuntime(deps: GatewayHostRuntimeDeps): GatewayH
// reads NEMOCLAW_GATEWAY_BIND_ADDRESS at load, and callers that reload
// onboarding with a different environment drop it from the require cache.
// A hoisted binding would pin this module to the stale first instance.
const { getGatewayStartNetworkEnv } =
require("./docker-driver-gateway-env") as typeof import("./docker-driver-gateway-env");
const gatewayEnv = getGatewayStartNetworkEnv(deps.gatewayPort());
const gatewayPort = deps.gatewayPort();
const gatewayEnv = deps.getGatewayStartNetworkEnv
? deps.getGatewayStartNetworkEnv(gatewayPort)
: (
require("./docker-driver-gateway-env") as typeof import("./docker-driver-gateway-env")
).getGatewayStartNetworkEnv(gatewayPort);
const openshellVersion = deps.getInstalledOpenshellVersion();
if (openshellVersion) {
const stableGatewayImage = `ghcr.io/nvidia/openshell/cluster:${openshellVersion}`;
Expand Down
Loading