fix(podman): time out detached launches

This commit is contained in:
Vincent Koc
2026-05-26 13:12:49 +02:00
parent 5b49433535
commit 8307e2f762
2 changed files with 24 additions and 2 deletions

View File

@@ -36,6 +36,14 @@ fail() {
exit 1
}
run_podman_detached() {
if command -v timeout >/dev/null 2>&1; then
timeout "$PODMAN_RUN_TIMEOUT" podman run "$@"
return
fi
podman run "$@"
}
validate_single_line_value() {
local label="$1"
local value="$2"
@@ -167,7 +175,7 @@ load_podman_env_file() {
key="${key%"${key##*[![:space:]]}"}"
[[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]] || continue
case "$key" in
OPENCLAW_GATEWAY_TOKEN|OPENCLAW_PODMAN_CONTAINER|OPENCLAW_PODMAN_IMAGE|OPENCLAW_IMAGE|OPENCLAW_PODMAN_PULL|OPENCLAW_PODMAN_GATEWAY_HOST_PORT|OPENCLAW_GATEWAY_PORT|OPENCLAW_PODMAN_BRIDGE_HOST_PORT|OPENCLAW_BRIDGE_PORT|OPENCLAW_GATEWAY_BIND|OPENCLAW_PODMAN_USERNS|OPENCLAW_BIND_MOUNT_OPTIONS|OPENCLAW_PODMAN_PUBLISH_HOST)
OPENCLAW_GATEWAY_TOKEN|OPENCLAW_PODMAN_CONTAINER|OPENCLAW_PODMAN_IMAGE|OPENCLAW_IMAGE|OPENCLAW_PODMAN_PULL|OPENCLAW_PODMAN_RUN_TIMEOUT|OPENCLAW_PODMAN_GATEWAY_HOST_PORT|OPENCLAW_GATEWAY_PORT|OPENCLAW_PODMAN_BRIDGE_HOST_PORT|OPENCLAW_BRIDGE_PORT|OPENCLAW_GATEWAY_BIND|OPENCLAW_PODMAN_USERNS|OPENCLAW_BIND_MOUNT_OPTIONS|OPENCLAW_PODMAN_PUBLISH_HOST)
;;
*)
continue
@@ -236,6 +244,7 @@ WORKSPACE_DIR="${OPENCLAW_WORKSPACE_DIR:-$CONFIG_DIR/workspace}"
CONTAINER_NAME="${OPENCLAW_PODMAN_CONTAINER:-openclaw}"
OPENCLAW_IMAGE="${OPENCLAW_PODMAN_IMAGE:-${OPENCLAW_IMAGE:-openclaw:local}}"
PODMAN_PULL="${OPENCLAW_PODMAN_PULL:-never}"
PODMAN_RUN_TIMEOUT="${OPENCLAW_PODMAN_RUN_TIMEOUT:-600s}"
HOST_GATEWAY_PORT="${OPENCLAW_PODMAN_GATEWAY_HOST_PORT:-${OPENCLAW_GATEWAY_PORT:-18789}}"
HOST_BRIDGE_PORT="${OPENCLAW_PODMAN_BRIDGE_HOST_PORT:-${OPENCLAW_BRIDGE_PORT:-18790}}"
PUBLISH_HOST="${OPENCLAW_PODMAN_PUBLISH_HOST:-127.0.0.1}"
@@ -546,7 +555,7 @@ if [[ "$RUN_SETUP" == true ]]; then
fi
TOKEN_ENV_FILE="$(create_token_env_file "$ENV_FILE" "$OPENCLAW_GATEWAY_TOKEN")"
podman run --pull="$PODMAN_PULL" -d --replace \
run_podman_detached --pull="$PODMAN_PULL" -d --replace \
--name "$CONTAINER_NAME" \
--init \
"${USERNS_ARGS[@]}" "${RUN_USER_ARGS[@]}" \

View File

@@ -4,6 +4,7 @@ import { describe, expect, it } from "vitest";
const SCRIPT_PATH = "scripts/test-install-sh-docker.sh";
const DOCKER_SETUP_PATH = "scripts/docker/setup.sh";
const PODMAN_SETUP_PATH = "scripts/podman/setup.sh";
const PODMAN_RUN_PATH = "scripts/run-openclaw-podman.sh";
const SMOKE_RUNNER_PATH = "scripts/docker/install-sh-smoke/run.sh";
const BUN_GLOBAL_SMOKE_PATH = "scripts/e2e/bun-global-install-smoke.sh";
const BUN_GLOBAL_ASSERTIONS_PATH = "scripts/e2e/lib/bun-global-install/assertions.mjs";
@@ -142,6 +143,18 @@ describe("test-install-sh-docker", () => {
expect(script).not.toContain('podman pull "$OPENCLAW_IMAGE"');
});
it("bounds detached Podman launches without timing out onboarding", () => {
const script = readFileSync(PODMAN_RUN_PATH, "utf8");
expect(script).toContain('PODMAN_RUN_TIMEOUT="${OPENCLAW_PODMAN_RUN_TIMEOUT:-600s}"');
expect(script).toContain("OPENCLAW_PODMAN_RUN_TIMEOUT|OPENCLAW_PODMAN_GATEWAY_HOST_PORT");
expect(script).toContain("run_podman_detached()");
expect(script).toContain('timeout "$PODMAN_RUN_TIMEOUT" podman run "$@"');
expect(script).toContain('podman run --pull="$PODMAN_PULL" --rm -it \\');
expect(script).toContain('run_podman_detached --pull="$PODMAN_PULL" -d --replace \\');
expect(script).not.toContain('podman run --pull="$PODMAN_PULL" -d --replace \\');
});
it("passes image-scoped pip packages through Docker and Podman setup", () => {
const dockerSetup = readFileSync(DOCKER_SETUP_PATH, "utf8");
const podmanSetup = readFileSync(PODMAN_SETUP_PATH, "utf8");