Skip to content

Commit aace0e1

Browse files
chrisguidryclaude
andauthored
Handle AlreadyExists race in cluster image build (#337)
`build_cluster_image` does a check-then-build that can race when parallel test sessions try to build the same image. The `images.get()` check passes for both, then one build succeeds and the other gets a `BuildError` with `AlreadyExists`. This showed up as every test failing in a CI cluster job: https://github.com/chrisguidry/docket/actions/runs/22020705636/job/63639829973 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61bc093 commit aace0e1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/_container.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,17 @@ def build_cluster_image(client: DockerClient, base_image: str) -> str:
177177
pass
178178

179179
cluster_dir = Path(__file__).parent / "cluster"
180-
client.images.build(
181-
path=str(cluster_dir),
182-
tag=tag,
183-
buildargs={"BASE_IMAGE": base_image},
184-
)
180+
try:
181+
client.images.build(
182+
path=str(cluster_dir),
183+
tag=tag,
184+
buildargs={"BASE_IMAGE": base_image},
185+
)
186+
except docker.errors.BuildError as e:
187+
if "AlreadyExists" in str(e):
188+
pass
189+
else:
190+
raise
185191
return tag
186192

187193

0 commit comments

Comments
 (0)