Skip to content

Wait for the image alias's pull before testImageAlias's health check - #8191

Merged
bartlomieju merged 1 commit into
mainfrom
biwanczuk/container-test-image-alias-wait
Nov 3, 2026
Merged

bartlomieju merged 1 commit into
mainfrom
biwanczuk/container-test-image-alias-wait

Conversation

@bartlomieju

Copy link
Copy Markdown
Collaborator

Summary

container-client-test:testImageAlias fails intermittently on main, in whichever variant
happens to be slow that run, with
TimeoutError: The operation was aborted due to timeout after 10 seconds:

This PR makes the test wait for start() to finish before its health check.

Cause

  • The test starts a container from the cloudflare/debian-trixie alias. It resolves to
    docker.io/library/node:24.20.0-trixie-slim@sha256:a747…, a linux/amd64 manifest with 85 MB of
    compressed layers.
  • start() pulls the image when the engine doesn't have it (ensureSystemImageAvailable()). The
    container tests run on a fresh Docker engine per variant, so every run pulls it from Docker Hub.
  • start() is fire-and-forget. The health check's first getTcpPort(8080).fetch() is issued while
    the pull is still running, and its AbortSignal.timeout(10_000) covers the pull.
  • When the pull takes longer than that, the fetch is aborted. waitUntilContainerIsHealthy()
    rethrows anything other than "not listening", so it doesn't retry.

Fix

inspect() takes its RPC turn after start(), so awaiting it first waits out the pull with no
per-request timeout. The health check then only waits for the server in the container to listen.

The inspect() assertion moves ahead of the health check. It checks the alias reported for the
started container, which doesn't depend on the server listening.

Testing

On bazelflare, --runs_per_test=3 of all three variants, each on a fresh engine:

testImageAlias runs Failed Over 10s
Before 9 2 (both at 10.03s, TimeoutError) –
After 9 0 4 (10.3s, 10.6s, 11.4s, 19.6s)

bazel test --config=bazelflare //... passes.

Notes

The test still pulls from Docker Hub on every run. I looked at preloading the image with the other
test images, but a docker loaded copy doesn't satisfy the
name:tag@sha256:a747… check ensureSystemImageAvailable() does:

  • containerd image store: docker load records a synthesized digest for oci_load's
    docker-format tarball, or the wrapping index's digest for format = "oci".
  • classic store: docker load records no digest.

An OCI layout whose index.json points straight at the manifest does work, on the containerd
store only. oci_load doesn't produce one, so that would need a custom rule.

testImageAlias starts a container from `cloudflare/debian-trixie`, which
resolves to a node:24.20.0-trixie-slim manifest (85 MB compressed) that
start() pulls from Docker Hub when the engine doesn't have it. The
container tests run on a fresh Docker engine per test variant, so every
run pulls it.

start() is fire-and-forget, so the health check's first fetch was
issued while the pull was still running, and its 10 second
AbortSignal.timeout covered the pull. When the pull took longer, the
fetch was aborted with a TimeoutError, which the health check rethrows
rather than retrying, failing the test.

inspect() takes its RPC turn after start(), so awaiting it first waits
out the pull with no per-request timeout. The health check then only
waits for the server in the container to listen.
@bartlomieju
bartlomieju requested review from a team as code owners November 3, 2026 17:32

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — A one-file test change that correctly waits out the image pull before the health check. No findings.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

The fix relies on inspect() waiting for start() to finish, and the server code supports that: both go through the same RPC turn. The comment follows the repository's comment guidelines.


Reviewed commit: e17e14e0

@bartlomieju
bartlomieju merged commit fb6a063 into main Nov 3, 2026
23 checks passed
@bartlomieju
bartlomieju deleted the biwanczuk/container-test-image-alias-wait branch November 3, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants