question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Race condition exists for matrixed GitHub Actions for `use_existing_version_if_available = true`

See original GitHub issue

Background

While trying to run a job matrix using this Action to deploy to two environments simultaneously, the jobs failed if they started at the same time and were uploading the same (new) application version zip. Dropping the parallelism on this step fixed the problem (I now run this action without an environment, and then n times more after that completes with the environment populated from the matrix).

Obviously it would be ideal to not waste the computation & upload twice, but the upload step should tolerate the app version already existing at any point during the upload.

Steps to Reproduce

  1. Run a matrixed deployment, as per the yml snippet below
multi-deploy:
    name: "Deploy Elastic Beanstalk"
    runs-on: ubuntu-latest
    strategy:
      matrix:
        environment_name: [ a, b, c ]
    steps:
      - name: Download deployment artifact
        uses: actions/download-artifact@v2
        with:
          name: eb-app-zip
      - name: Upload application zip to S3 and create EB application version
        uses: einaregilsson/beanstalk-deploy@v16
        with:
          aws_access_key: ${{ secrets.EB_AWS_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.EB_AWS_SECRET_ACCESS_KEY }}
          application_name: ${{ inputs.application_name }}
          environment_name: ${{ matrix.environment_name }}
          version_label: ${{ inputs.version_label }}
          version_description: Commit ${{github.sha}} deployed by github actions
          region: ${{ inputs.aws_region }}
          deployment_package: deploy.zip
          use_existing_version_if_available: true
          wait_for_deployment: true
          wait_for_environment_recovery: 60

Expected Result

One of the uploads “wins” and the others fall in line and use that app version (“already existing”)

Actual Result

One of the uploads “wins” and the other jobs error out, crashing themselves and the winning upload’s job, too.

Example Failure Output

The bucket name and key have been changed to basic values.

Uploading file to bucket mybucket
New build successfully uploaded to S3, bucket=mybucket, key=/myuniquekey/deploy-COMMITSHA.zip
Error: Deployment failed: Error: Status: 400. Code: InvalidParameterValue, Message: Application Version deploy-COMMITSHA already exists.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
einaregilssoncommented, Dec 1, 2021

Ok, this is officially out as v19. 🙂

1reaction
n-hebertcommented, Nov 18, 2021

True – that would be a good idea. I’ll dig a bit into seeing if there’s a way to tell if we’re in a matrix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix potential race condition in restoring checkpoints. - GitHub
# The below step just reports the success or failure of tests as a "commit status". # This is needed for copybara integration....
Read more >
(aws-apigateway): race condition between Stage and ... - GitHub
When cloudWatchRole is enabled, a CfnAccount is created for it. Since there is no explicit dependency between the the stages and the account, ......
Read more >
Workflow syntax for GitHub Actions
A workflow is a configurable automated process made up of one or more jobs. You must create a YAML file to define your...
Read more >
Race condition when creating GitHub releases · Issue #2799
The script that uploads Linux builds creates the GitHub release if it doesn't exist yet, and always creates it as a prerelease: ...
Read more >
Run a matrix element only if a condition is true #9044 - GitHub
I believe this is better than having two identical jobs just with a different matrix. If there is already a good way to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found