Skip to content

Commit 35310dc

Browse files
committed
fix(setup): kill timed image pulls when supported
1 parent 8685dbd commit 35310dc

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

scripts/docker/setup.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ run_docker_build() {
3737
run_docker_pull() {
3838
local image="$1"
3939
if command -v timeout >/dev/null 2>&1; then
40-
timeout "$DOCKER_PULL_TIMEOUT" docker pull "$image"
40+
if timeout --kill-after=1s 1s true >/dev/null 2>&1; then
41+
timeout --kill-after=30s "$DOCKER_PULL_TIMEOUT" docker pull "$image"
42+
else
43+
timeout "$DOCKER_PULL_TIMEOUT" docker pull "$image"
44+
fi
4145
return
4246
fi
4347
docker pull "$image"

scripts/podman/setup.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ fail() {
4747
run_podman_pull() {
4848
local image="$1"
4949
if command -v timeout >/dev/null 2>&1; then
50-
timeout "$PODMAN_PULL_TIMEOUT" podman pull "$image"
50+
if timeout --kill-after=1s 1s true >/dev/null 2>&1; then
51+
timeout --kill-after=30s "$PODMAN_PULL_TIMEOUT" podman pull "$image"
52+
else
53+
timeout "$PODMAN_PULL_TIMEOUT" podman pull "$image"
54+
fi
5155
return
5256
fi
5357
podman pull "$image"

test/scripts/test-install-sh-docker.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ describe("test-install-sh-docker", () => {
126126

127127
expect(script).toContain('DOCKER_PULL_TIMEOUT="${OPENCLAW_DOCKER_SETUP_PULL_TIMEOUT:-600s}"');
128128
expect(script).toContain("run_docker_pull()");
129+
expect(script).toContain("timeout --kill-after=1s 1s true");
130+
expect(script).toContain('timeout --kill-after=30s "$DOCKER_PULL_TIMEOUT" docker pull "$image"');
129131
expect(script).toContain('timeout "$DOCKER_PULL_TIMEOUT" docker pull "$image"');
130132
expect(script).toContain('run_docker_pull "$IMAGE_NAME"');
131133
expect(script).not.toContain('docker pull "$IMAGE_NAME"');
@@ -138,6 +140,8 @@ describe("test-install-sh-docker", () => {
138140
'PODMAN_PULL_TIMEOUT="${OPENCLAW_PODMAN_SETUP_PULL_TIMEOUT:-600s}"',
139141
);
140142
expect(script).toContain("run_podman_pull()");
143+
expect(script).toContain("timeout --kill-after=1s 1s true");
144+
expect(script).toContain('timeout --kill-after=30s "$PODMAN_PULL_TIMEOUT" podman pull "$image"');
141145
expect(script).toContain('timeout "$PODMAN_PULL_TIMEOUT" podman pull "$image"');
142146
expect(script).toContain('run_podman_pull "$OPENCLAW_IMAGE"');
143147
expect(script).not.toContain('podman pull "$OPENCLAW_IMAGE"');

0 commit comments

Comments
 (0)