From 2d90a181df2f5ce7ceac74bba4831012088ce7f7 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Tue, 10 Nov 2026 17:58:51 -0800 Subject: [PATCH] test: the bootstrap images are built one worker at a time Test workers share one Docker daemon, and two first builds of one tag at the same moment both create it, so the second fails with "image ...: already exists". _seed_bootstrap_envs, which about a dozen integration test files call, builds four fixed tags; it now holds a lock while it builds each. Co-Authored-By: Claude Opus 5.5 --- tst/integration/store/local_parallel_deploy_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tst/integration/store/local_parallel_deploy_test.py b/tst/integration/store/local_parallel_deploy_test.py index 4acc1e9d8..124424fd6 100644 --- a/tst/integration/store/local_parallel_deploy_test.py +++ b/tst/integration/store/local_parallel_deploy_test.py @@ -9,9 +9,11 @@ """ import contextlib +import fcntl import json import socket import subprocess +import tempfile import time import uuid from pathlib import Path @@ -34,6 +36,9 @@ pytestmark = [pytest.mark.integration, pytest.mark.int_test_slow] _TST_DATA = Path(__file__).resolve().parents[2] / "data" +# Test workers share one Docker daemon, and two builds naming the same tag at once can fail with +# "image ... already exists", so the bootstrap builds take turns. +_BUILD_LOCK = Path(tempfile.gettempdir()) / "agentenv-test-bootstrap-builds.lock" def _free_port() -> int: @@ -115,7 +120,9 @@ def _seed_bootstrap_envs(): from agent_env.env.envs.service_db import ServiceDBEnv def build(dockerfile: Path, context: Path, tag: str) -> DockerImageArtifact: - result = _docker("build", "-f", str(dockerfile), "-t", tag, str(context)) + with open(_BUILD_LOCK, "w") as lock: + fcntl.flock(lock, fcntl.LOCK_EX) + result = _docker("build", "-f", str(dockerfile), "-t", tag, str(context)) assert result.returncode == 0, f"build {tag} failed: {result.stderr[-2000:]}" return DockerImageArtifact.put(id=tag, description="bootstrap", image_name=tag)