Repository navigation
ci(gitlab): use a per-pipeline BuildKit builder instead of a persistent one - #482
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
docker buildx createis still a single-shot operation and will fail for concurrent jobs racing to… · New Withneeds, GitLab can schedule thisfinalizejob as soon asspack-cache-cleanupfinishes,… · New This API call is unauthenticated; if the project/pipeline endpoint requires auth, it may return… · New Preferapk add --no-cachein CI to avoid persisting the package index and to reduce job time and… · New
What changed in this PR
Move GitLab CI builds from a shared persistent BuildKit builder to a per-pipeline builder to prevent cross-pipeline session/cache interference and reduce flakiness on concurrent builds.
Changes:
- Introduces
BUILDER_NAME(defaultbuilder-${CI_PIPELINE_ID}) and updates build setup to use it. - Splits BuildKit bootstrapping into a retryable
buildx inspect --bootstraploop. - Adds a
clean_builder:docker-newfinalize job to remove per-pipeline builders and sweep builders from finished pipelines; documents behavior inAGENTS.md.
| File | Description |
|---|---|
AGENTS.md |
Documents per-pipeline BuildKit builder behavior and cleanup job. |
.gitlab-ci.yml |
Adds BUILDER_NAME, changes buildx initialization/bootstrapping, and introduces finalize cleanup job. |
Review effort: Lite
Copilot stopped reviewing on behalf of
wdconinc due to an error
November 1, 2026 17:40
Contributor
wdconinc
force-pushed
the
ccr-616d5ca1-vga0gi-per-pipeline-builder
branch
from
November 2, 2026 22:38
5413217 to
abb6639
Compare
wdconinc
force-pushed
the
ccr-616d5ca1-vga0gi-per-pipeline-builder
branch
from
November 3, 2026 20:18
abb6639 to
916d678
Compare
This was referenced Nov 3, 2026
wdconinc
pushed a commit
that referenced
this pull request
Nov 4, 2026
GitLab builds imported four Docker layer caches per build: the branch and master tags on both eicweb and ghcr.io/eic/buildcache. The ghcr.io caches are written by GitHub Actions builds, never by GitLab, and give BuildKit a second set of records that can match the same cache keys as eicweb's. In #482's pipelines, base builds with identical inputs matched some steps and then missed the following ones, and mixing records from several cache sources is one suspected cause. scripts/build-base.sh and scripts/build-eic.sh now import only the CI system's own registry in CI mode (GitLab: eicweb, as before also the only cache destination; GitHub: ghcr.io, unchanged), and the public ghcr.io caches only for local builds (unchanged). docs/build-pipeline.md describes the GitLab and local cache sources. The Spack binary buildcache mirrors (mirrors.yaml.in, including the ghcr mirror that GitLab reads and pushes to) are not changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qEz4vCZUkz3xKJYKfcaaf
wdconinc
added a commit
that referenced
this pull request
Nov 5, 2026
GitLab builds imported four Docker layer caches per build: the branch and master tags on both eicweb and ghcr.io/eic/buildcache. The ghcr.io caches are written by GitHub Actions builds, never by GitLab, and give BuildKit a second set of records that can match the same cache keys as eicweb's. In #482's pipelines, base builds with identical inputs matched some steps and then missed the following ones, and mixing records from several cache sources is one suspected cause. scripts/build-base.sh and scripts/build-eic.sh now import only the CI system's own registry in CI mode (GitLab: eicweb, as before also the only cache destination; GitHub: ghcr.io, unchanged), and the public ghcr.io caches only for local builds (unchanged). docs/build-pipeline.md describes the GitLab and local cache sources. The Spack binary buildcache mirrors (mirrors.yaml.in, including the ghcr mirror that GitLab reads and pushes to) are not changed. Claude-Session: https://claude.ai/code/session_019qEz4vCZUkz3xKJYKfcaaf Co-authored-by: Claude <noreply@anthropic.com>
wdconinc
force-pushed
the
ccr-616d5ca1-vga0gi-per-pipeline-builder
branch
from
November 5, 2026 16:09
916d678 to
3ec3a53
Compare
…nt one
All GitLab build jobs on eic-n0 shared one persistent docker-container
builder ("builder") across pipelines. Concurrent builds from different
pipelines on that instance hit "no active session" errors for lazily
imported cache layers and "unknown blob ... in history" when blobs were
garbage-collected under them.
- BUILDER_NAME (default builder-${CI_PIPELINE_ID}) names the builder; all
build jobs of a pipeline share it, jobs of different pipelines do not.
Setting BUILDER_NAME=builder restores the persistent instance.
- Bootstrap is retried, since concurrent jobs of a pipeline race to
create the builder container.
- clean_builder:docker-new removes this pipeline's builder after
spack-cache-cleanup, and the builders of other finished pipelines,
since canceled pipelines never reach the finalize stage.
Registry layer caching (--cache-from/--cache-to) is unchanged: a fresh
builder relies on it for layer reuse. Cache mounts (ccache, spack
sources, concretization cache) now start empty in every pipeline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019qEz4vCZUkz3xKJYKfcaaf
wdconinc
force-pushed
the
ccr-616d5ca1-vga0gi-per-pipeline-builder
branch
from
November 5, 2026 22:48
3ec3a53 to
40c6dcd
Compare
- Remove the builder in its own builder-cleanup stage after finalize, instead of a finalize job with needs on spack-cache-cleanup: without needs, clean_builder only starts once every job of all earlier stages (including spack-cache-cleanup) has finished. - Make builder creation idempotent: fall back to `docker buildx use` if `docker buildx create` reports an existing builder. (Each job container starts with an empty buildx config, so this is a safeguard; concurrent jobs race only at bootstrap, which is retried.) - Document that a job retried after clean_builder ran re-creates the builder (empty, layers from the registry cache), and that the sweep in later pipelines removes it once its pipeline has finished again. - apk add --no-cache in clean_builder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qEz4vCZUkz3xKJYKfcaaf
veprbl
approved these changes
Nov 7, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
All GitLab build jobs on eic-n0 share one persistent
docker-containerbuilder namedbuilder, across pipelines. Concurrent builds from different pipelines on that instance are linked to two recurring failures:no active session for …: context deadline exceeded: a lazily imported cache layer was bound to another build's session.unknown blob sha256:… in history: blobs were garbage-collected while another build still referenced them.Change
BUILDER_NAME: new global variable, defaultbuilder-${CI_PIPELINE_ID}. All build jobs of one pipeline share an instance. Jobs of different pipelines no longer do.BUILDER_NAME=builderto get the old persistent instance back, with no revert needed.createno longer bootstraps. A separatebuildx inspect --bootstrapstep retries up to 3 times, because the threebasejobs start together and race to create the same container.clean_builder:docker-new: newfinalizejob,when: always. It runs afterspack-cache-cleanupand removes this pipeline's builder container and state volume. It also sweeps builders of other finished pipelines (success, failed, canceled, skipped), because canceled pipelines never reachfinalize. It never removes the persistentbuilder. It uses the same unauthenticated pipeline-status API call asclean_pipeline.AGENTS.md: documents the above.Independence from #480 and #481
This PR branches from
masterand does not touch any registry layer cache settings. All images, CUDA included, keep--cache-fromand--cache-to, so this change can be judged on its own. The three branches merge intomastertogether without conflicts, and the merged YAML parses.If this PR and #481 are both merged, CUDA images get no layer reuse across pipelines at all. They keep reuse within a job, between the default and nightly builds, plus the Spack buildcache.
Known trade-offs
/ccache,/var/cache/spackand the concretization cache. Nightly EICrecon and epic compiles run without ccache, and sources are downloaded again.baseimages are rebuilt in every pipeline, so any change in their digest invalidates everyeicstage in an imported cache. A persistent builder masks that through local state.builder_concretization_defaultandbuilder_installation_defaultsteps showCACHEDin aneic_cioreic_xljob on amasterpipeline.spack-cache-cleanupbecomes nearly a no-op with per-pipeline builders. It is kept for theBUILDER_NAME=buildermode.buildx_buildkit_builder0container and volume stay on eic-n0 until someone removes or prunes them.Validation
.gitlab-ci.ymlparses, both alone and merged with ci(gitlab): skip non-debian base images for epic/EICrecon triggers #480 and ci(gitlab): no registry layer cache for CUDA-based EIC images #481.dashwith stubbeddockerandcurl:builder.0parse correctly.Generated by Claude Code