Skip to content

fix(ci): retry buildx create in builder setup; harden clean_builder - #504

Merged
wdconinc merged 1 commit into
masterfrom
claude/blissful-galileo-sqivse
Nov 13, 2026
Merged

wdconinc merged 1 commit into
masterfrom
claude/blissful-galileo-sqivse

Conversation

@wdconinc

Copy link
Copy Markdown
Contributor

Briefly, what does this PR introduce?

Two GitLab CI robustness fixes around the per-pipeline BuildKit builder (BUILDER_NAME).

1. Race on docker buildx create (eicweb job 8767659)

Two jobs of pipeline 152034 started at the same moment on eic-n0 (base-cuda: [cuda_runtime] and base: [debian_stable_base]):

cuda_runtime 22:11:10.37 buildx create → OK (no container yet → node inactive, no connection)
cuda_runtime 22:11:11.14 bootstrap: creating container buildx_buildkit_builder-1520340
debian       22:11:11.33 buildx create → container running, buildkitd not yet listening
                         "failed to initialize builder ... listing workers"
                         → buildx drops the builder from this job's config
debian       22:11:12.69 fallback `buildx use` → "failed to find instance" → exit 1
cuda_runtime 22:11:12.98 container done
  • buildx create connects to a running builder container to list workers, so the race shows up there, not at bootstrap as the comment assumed.
  • When that check fails, buildx removes the builder entry it just wrote. Each job starts with an empty buildx config, so the || docker buildx use fallback can't recover, and the job exits before the bootstrap retry loop runs.
  • The window is about 2 s, but every pipeline opens it because all base and base-cuda jobs start together.

Fix: retry create || use together with inspect --bootstrap (5 attempts, 10 s apart). After a successful create, a later attempt fails on the existing name and use selects it. I also updated the comment.

2. clean_builder aborted by a bad API response (eicweb job 8746912)

One pipelines-API curl took 5 min and returned non-JSON. jq then failed ("Invalid numeric literal") and the job exited (code 5), so it skipped the remaining stale builders. Now curl --fail --max-time 30 is used, and a failed or unparseable response leaves the status empty, so that builder is kept and the loop continues.

Testing

  • YAML parses, and the folded before_script line is valid bash.
  • Ran the loop under bash -eo pipefail with a stubbed docker:
    • create fails once, then succeeds: recovers, exit 0.
    • create always fails: 5 attempts, exit 1.
  • The jq line with a non-JSON input gives an empty status and doesn't exit.
  • Not yet run on GitLab CI.

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Documentation update
  • Other

Generated by Claude Code

Concurrent jobs of a pipeline (e.g. base and base-cuda) share one BuildKit
builder. If one job has just started the buildx_buildkit_* container and
buildkitd is not yet listening, `docker buildx create` in the other job
fails ("listing workers: ... buildkitd.sock: no such file or directory")
and drops the builder from that job's buildx config, so the
`|| docker buildx use` fallback also fails and the job exits before the
bootstrap retries (eicweb job 8767659). Retry create/use together with
the bootstrap.

In clean_builder, a slow or non-JSON pipelines API response made jq fail
and aborted the job (eicweb job 8746912). Bound curl with --fail and
--max-time and treat an unparseable response as unknown status (builder
kept).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019qEz4uqoKa2R5BVLBKSyhx
Copilot AI balanced review requested due to automatic review settings November 12, 2026 22:20
@wdconinc
wdconinc enabled auto-merge (squash) November 12, 2026 22:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🔵 Needs a closer look

The change alters GitLab CI builder creation/cleanup on shared runners and, because its correctness depends on real GitLab runner concurrency and Docker Buildx/BuildKit timing/API behavior, it should be validated by an actual pipeline run before proceeding.

No open issues 🎉

What changed in this PR

Improves GitLab CI robustness for per-pipeline BuildKit builders by mitigating a buildx startup race and making stale-builder cleanup resilient to flaky GitLab API responses.

Changes:

  • Retry docker buildx create || docker buildx use together with docker buildx inspect --bootstrap to handle transient builder readiness/concurrency races.
  • Harden clean_builder by bounding/failing curl safely and tolerating non-JSON/failed API responses so the cleanup loop continues.
File Description
.gitlab-ci.yml Adds retry logic around Buildx builder selection/bootstrapping and hardens the stale builder cleanup loop against slow/failed/non-JSON GitLab API responses.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Capybara summary for PR 504

@wdconinc
wdconinc requested review from a team and veprbl November 13, 2026 14:57
@wdconinc
wdconinc merged commit 5b710c3 into master Nov 13, 2026
96 checks passed
@wdconinc
wdconinc deleted the claude/blissful-galileo-sqivse branch November 13, 2026 17:41

This branch was previously deployed

1 inactive deployment
github-pages — 30216575 Deployed Nov 13, 2026 by wdconinc via deploy-artifacts-page #4607
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.

4 participants