mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(cli): bound container runtime probes (#109199)
Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: Peter Steinberger <peter@steipete.me>
This commit is contained in:
co-authored by
Peter Steinberger
Peter Steinberger
parent
2a52e45e2b
commit
91df2d1812
@@ -406,7 +406,7 @@ describe("maybeRunCliInContainer", () => {
|
||||
1,
|
||||
"podman",
|
||||
["inspect", "--format", "{{.State.Running}}", "demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
expect(spawnSync).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
@@ -459,7 +459,7 @@ describe("maybeRunCliInContainer", () => {
|
||||
2,
|
||||
"docker",
|
||||
["inspect", "--format", "{{.State.Running}}", "demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
expect(spawnSync).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
@@ -516,13 +516,13 @@ describe("maybeRunCliInContainer", () => {
|
||||
1,
|
||||
"podman",
|
||||
["inspect", "--format", "{{.State.Running}}", "demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
expect(spawnSync).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
"docker",
|
||||
["inspect", "--format", "{{.State.Running}}", "demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
expect(spawnSync).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
@@ -570,13 +570,13 @@ describe("maybeRunCliInContainer", () => {
|
||||
1,
|
||||
"podman",
|
||||
["inspect", "--format", "{{.State.Running}}", "demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
expect(spawnSync).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
"docker",
|
||||
["inspect", "--format", "{{.State.Running}}", "demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -681,7 +681,7 @@ describe("maybeRunCliInContainer", () => {
|
||||
1,
|
||||
"podman",
|
||||
["inspect", "--format", "{{.State.Running}}", "flag-demo"],
|
||||
{ encoding: "utf8" },
|
||||
{ encoding: "utf8", killSignal: "SIGKILL", timeout: 10_000 },
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ type ContainerRuntimeExec = {
|
||||
};
|
||||
|
||||
const CONTAINER_ALLOW_LOOPBACK_PROXY_URL_ENV = "OPENCLAW_CONTAINER_ALLOW_LOOPBACK_PROXY_URL";
|
||||
const CONTAINER_RUNTIME_PROBE_TIMEOUT_MS = 10_000;
|
||||
|
||||
export function parseCliContainerArgs(argv: string[]): CliContainerParseResult {
|
||||
let container: string | null = null;
|
||||
@@ -74,8 +75,17 @@ function isContainerRunning(params: {
|
||||
params.exec.command,
|
||||
[...params.exec.argsPrefix, "inspect", "--format", "{{.State.Running}}", params.containerName],
|
||||
params.exec.command === "sudo"
|
||||
? { encoding: "utf8", stdio: ["inherit", "pipe", "inherit"] }
|
||||
: { encoding: "utf8" },
|
||||
? {
|
||||
encoding: "utf8",
|
||||
killSignal: "SIGKILL",
|
||||
stdio: ["inherit", "pipe", "inherit"],
|
||||
timeout: CONTAINER_RUNTIME_PROBE_TIMEOUT_MS,
|
||||
}
|
||||
: {
|
||||
encoding: "utf8",
|
||||
killSignal: "SIGKILL",
|
||||
timeout: CONTAINER_RUNTIME_PROBE_TIMEOUT_MS,
|
||||
},
|
||||
);
|
||||
return result.status === 0 && result.stdout.trim() === "true";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user