Skip to content

cache-image: true causes "Unable to reserve cache" warning in parallel matrix builds #306

Description

@arsalanyavari

Contributing guidelines

I've found a bug, and:

  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem

Description

Description:

When using setup-qemu-action in a matrix build with multiple platforms, parallel jobs within the same workflow run all try to save the binfmt image to GitHub Actions cache using the same cache key simultaneously. This causes a warning on all jobs except the first one that wins the race.

Warning:

Failed to save: Unable to reserve cache with key
docker.io--tonistiigi--binfmt-latest-linux-x64,
another job may be creating this cache.

Root Cause:

The cache key is built from the image name + tag + runner OS/arch: docker.io--tonistiigi--binfmt-latest-linux-x64

Since all platform matrix jobs (including linux/arm64, linux/arm/v7, etc.) run on the same ubuntu-latest runner (x64), they all produce the identical cache key and compete to write it in parallel.

The issue is in @docker/actions-toolkit's Docker.pull() — it always attempts to save to cache after a successful pull, even when multiple jobs are running concurrently.

Expected behaviour

No warning while using matrix multi platform.

Actual behaviour

All jobs except one print the warning. Build still succeeds (warning is non-fatal), but it's noisy and confusing.

Repository URL

https://github.com/rosen-bridge/guard-service

Workflow run URL

https://github.com/rosen-bridge/guard-service/actions/runs/27794152893

YAML workflow

strategy:
  matrix:
    platform:
      - linux/amd64
      - linux/arm64
      - linux/arm/v7

steps:
  - name: Set up QEMU
    uses: docker/setup-qemu-action@v3
    # cache-image defaults to true

Workflow logs

Image

BuildKit logs


Additional info

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions