Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] v4: overwrite: true fails with parallel jobs writing to the artifact #506

Open
yury-s opened this issue Jan 25, 2024 · 8 comments
Open
Labels
bug Something isn't working

Comments

@yury-s
Copy link

yury-s commented Jan 25, 2024

What happened?

When setting overwrite: true, upload sometimes fails with the following output:

Run actions/upload-artifact@v4
  with:
    name: pull-request-number
    path: pull_request_number.txt
    overwrite: true
    if-no-files-found: warn
    compression-level: 6
  env:
    FORCE_COLOR: 1
    FLAKINESS_CONNECTION_STRING: 
    ELECTRON_SKIP_BINARY_DOWNLOAD: 1
    PWTEST_BOT_NAME: ubuntu-latest-node18-1
With the provided path, there will be 1 file uploaded
Artifact name is valid!
Root directory input is valid!
Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run

What did you expect to happen?

One of the job succeeded and other silently continue doing nothing as documentation of the option suggests.

How can we reproduce it?

Configure several parallel jobs within a workflow and matrixes to write into the same artifact with overwrite: true, something like this:

    - name: Upload artifact with the pull request number
      if: always() && github.event_name == 'pull_request'
      uses: actions/upload-artifact@v4
      with:
        name: pull-request-number
        path: pull_request_number.txt
        overwrite: true

The upload action will fail sometimes, e.g. see this run.

Anything else we need to know?

No response

What version of the action are you using?

v4.3.0

What are your runner environments?

linux, window, macos

Are you on GitHub Enterprise Server? If so, what version?

No response

@yury-s yury-s added the bug Something isn't working label Jan 25, 2024
yury-s added a commit to yury-s/playwright that referenced this issue Jan 25, 2024
Reverting parts of microsoft#29080 related to use of overwrite: true as it is racy and fails time to time with parallel jobs.

Reference actions/upload-artifact#506
yury-s added a commit to yury-s/playwright that referenced this issue Jan 25, 2024
Reverting parts of microsoft#29080 related to use of overwrite: true as it is racy and fails time to time with parallel jobs.

Reference actions/upload-artifact#506
yury-s added a commit to microsoft/playwright that referenced this issue Jan 25, 2024
@melloware
Copy link

I get this error as well https://github.com/open-sce/fluent-cli/actions/runs/7254116343/job/19762158254

Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run

@darthcloud
Copy link

darthcloud commented Feb 3, 2024

Updated to v4 as well due to Node.js warning, added overwrite: true and still getting the error:
https://github.com/darthcloud/BlueRetro/actions/runs/7768402627/workflow

@melloware
Copy link

I even tried v4.3.0 just to make sure it was using the latest version and the same error happens.

@melloware
Copy link

I was able to fix my problem by following the migration guide:https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md

See my commit: open-sce/fluent-cli@900fed5

@moos3
Copy link

moos3 commented Mar 19, 2024

I'm running into the this issue Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run only on some builds, not always. I'm doing this as the upload

- name: Upload meta bake definition
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.version }}-onbuild-poetry-bake-meta
          path: /tmp/bake-meta.json
          if-no-files-found: error
          overwrite: true

Isn't the whole point of overwrite, to overwrite it and not care if that artifact is already there?

@JonathanAtCenterEdge
Copy link

Getting this exact same issue, randomly with overrwrite: true my workflows are failing with a 409 conflict

@darthcloud
Copy link

I don't understand why you are deprecating v3:
https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/

When v4 is still broken on parallel job setup.

@robherley
Copy link
Contributor

👋 I want to clarify that the overwrite operation is not atomic. It simply is a helper to delete the artifact before creating a new one.

The intended purpose of this overwrite feature was not for parallel jobs. It was meant for serial overwriting (like uploading a binary, then downloading it, signing it, then reuploading it).

If you are trying to upload to the same artifact name across parallel jobs, you will hit race conditions. This does not merge artifacts across jobs. If you have jobs A, B and C and they all try to upload my-artifact with overwrite: true, only the contents from one of the job's artifacts will be contained, the last one that wrote. The uploads from the other jobs would be just wasted time. You would be better off skipping the other jobs with a conditional if you do not care about the artifact contents to save runtime costs.

However, if you do care about the artifact contents from multiple concurrent jobs, you simply need to give the artifacts different names (like variables of your parallel matrix) and call actions/upload-artifact/merge which is outlined in the migration guide: https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md#merging-multiple-artifacts

This is exactly what @melloware stated above and implemented in their workflow, and is the correct solution for v4 due to the key differences of how this new major version works.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants
@moos3 @darthcloud @melloware @yury-s @robherley @JonathanAtCenterEdge and others