mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
fix(gateway): keep liveness probes working when config reload fails (#126736)
This commit is contained in:
committed by
GitHub
parent
d8c3d94fb1
commit
ddb49f61ca
@@ -903,21 +903,32 @@ describe("gateway probe endpoints", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("serves /healthz before loading gateway config", async () => {
|
||||
it("serves liveness probes before loading gateway config or resolving auth", async () => {
|
||||
const getRuntimeConfig = vi.fn(() => {
|
||||
throw new Error("config load blocked");
|
||||
});
|
||||
const getResolvedAuth = vi.fn(() => {
|
||||
getRuntimeConfig();
|
||||
return AUTH_NONE;
|
||||
});
|
||||
|
||||
await withGatewayServer({
|
||||
prefix: "probe-healthz-before-config",
|
||||
prefix: "probe-liveness-before-config-auth",
|
||||
resolvedAuth: AUTH_NONE,
|
||||
overrides: { getRuntimeConfig },
|
||||
overrides: { getRuntimeConfig, getResolvedAuth },
|
||||
run: async (server) => {
|
||||
const { res, getBody } = await sendGatewayRequest(server, { path: "/healthz" });
|
||||
for (const path of ["/health", "/healthz"]) {
|
||||
for (const method of ["GET", "HEAD"] as const) {
|
||||
const { res, getBody } = await sendGatewayRequest(server, { path, method });
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(getBody()).toBe(JSON.stringify({ ok: true, status: "live" }));
|
||||
expect(res.statusCode, `${method} ${path}`).toBe(200);
|
||||
expect(getBody(), `${method} ${path}`).toBe(
|
||||
method === "HEAD" ? "" : JSON.stringify({ ok: true, status: "live" }),
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(getRuntimeConfig).not.toHaveBeenCalled();
|
||||
expect(getResolvedAuth).not.toHaveBeenCalled();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -257,7 +257,7 @@ export function createGatewayHttpServer(opts: {
|
||||
req,
|
||||
res,
|
||||
requestPath,
|
||||
getResolvedAuth(),
|
||||
resolvedAuth,
|
||||
[],
|
||||
false,
|
||||
rateLimiter,
|
||||
|
||||
Reference in New Issue
Block a user