Skip to content

GAR error "cannot reuse body, request must be retried" #452

@bchrobot

Description

@bchrobot

Troubleshooting

Before submitting a bug report please read the Troubleshooting doc.

  • I have read TROUBLESHOOTING.md.

I wasn't sure from the "Cannot push to a registry" section whether your preference is for issues to be opened here or in the linked tools' repos.

Behaviour

Pushing image to GAR sometimes fails with error:

ERROR: failed commit on ref "manifest-sha256:0f17d0ea56a824cc2efa0ad1ded3e1dc540cdb3d0468feebb0b5506853c90f82": cannot reuse body, request must be retried

Steps to reproduce this issue

  1. Make and push a commit
  2. See build stage of build-push-action@v2 succeed
  3. See push stage of build-push-action@v2 fail with above error

It seems only to happen for commits that only touch files excluded from the Docker build context. However, the action does occasionally succeed this type of commit.

Expected behaviour

Push stage should succeed.

Actual behaviour

Push stage fails with error.

Configuration

name: CI/CD Pipeline

on:
  push:

jobs:
  publish-docker-image:
    if: github.ref == 'refs/heads/master'
    name: Publish Docker image
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        with:
          version: latest
          buildkitd-flags: --debug

      # Caching strategy from: https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
      - name: Cache Docker layers for ${{ matrix.service }}
        uses: actions/cache@v2
        with:
          path: /tmp/.buildx-cache
          key: ${{ runner.os }}-buildx-fly-shortener-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-buildx-fly-shortener-

      - name: Get image tags
        id: image-tags
        run: |
          export GIT_SHA="${{ github.sha }}"
          export GIT_SHA_SHORT=${GIT_SHA:0:7}
          echo "::set-output name=sha::$GIT_SHA_SHORT"

      - name: Login to GAR
        uses: docker/login-action@v1
        with:
          registry: us-east4-docker.pkg.dev
          username: _json_key
          password: ${{ secrets.GCR_JSON_KEY }}

      - name: Build and push ${{ matrix.service }}
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          push: true
          tags: |
            us-east4-docker.pkg.dev/assemble-services/apps/link-shortener:latest
            us-east4-docker.pkg.dev/assemble-services/apps/link-shortener:${{ steps.image-tags.outputs.sha }}
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache-new

      # Temp fix
      # https://github.com/docker/build-push-action/issues/252
      # https://github.com/moby/buildkit/issues/1896
      - name: Move cache
        run: |
          rm -rf /tmp/.buildx-cache
          mv /tmp/.buildx-cache-new /tmp/.buildx-cache

Logs

1_Set up job.txt
2_Checkout.txt
3_Set up Docker Buildx.txt
4_Cache Docker layers for.txt
5_Get image tags.txt
6_Login to GAR.txt
7_Build and push.txt
12_Post Build and push.txt
13_Post Login to GAR.txt
15_Post Set up Docker Buildx.txt
16_Post Checkout.txt
17_Complete job.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions