fix(plugin): bound kubernetes sandbox execution

This commit is contained in:
Dotta
2026-05-12 12:34:08 -05:00
committed by Chris Farhood
parent e691d30d12
commit 39d81c732c
5 changed files with 72 additions and 25 deletions
@@ -38,4 +38,13 @@ describe("execInPod", () => {
stderr: expect.stringContaining("websocket closed before status frame"),
});
});
it("returns an execution failure if the exec command exceeds its deadline", async () => {
execMock.mockResolvedValue(new EventEmitter());
const result = await execInPod({} as never, "ns", "pod-1", "agent", ["sleep", "60"], undefined, 5);
expect(result.exitCode).toBe(1);
expect(result.stderr).toContain("Kubernetes exec timed out after 5ms");
});
});
@@ -213,4 +213,16 @@ describe("waitForSandboxReady", () => {
}),
).rejects.toThrow(/failed.*OOMKilled/i);
});
it("fails fast when Sandbox starts terminating before it is ready", async () => {
const get = vi.fn().mockResolvedValue(makeCr("Terminating"));
const clients = { custom: { getNamespacedCustomObject: get } };
await expect(
waitForSandboxReady(clients as never, "ns", "pc-abc", {
timeoutMs: 5000,
pollMs: 10,
}),
).rejects.toThrow(/terminating before it became ready/i);
expect(get).toHaveBeenCalledTimes(1);
});
});