actions / upload-artifact

MIT License
3.25k stars 734 forks source link

[bug] Failed to CreateArtifact: Failed to make request after 5 attempts: Request timeout #569

Open lukaszcl opened 6 months ago

lukaszcl commented 6 months ago

What happened?

I'm seeing random failures in Github Actions when trying to upload artifacts:

2024-05-21T02:14:34.9725770Z With the provided path, there will be 9 files uploaded
2024-05-21T02:14:34.9727364Z Artifact name is valid!
2024-05-21T02:14:34.9728185Z Root directory input is valid!
2024-05-21T02:14:40.0221024Z Attempt 1 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 3000 ms...
2024-05-21T02:14:48.0300611Z Attempt 2 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 4541 ms...
2024-05-21T02:14:57.5783685Z Attempt 3 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 7858 ms...
2024-05-21T02:15:10.4508466Z Attempt 4 of 5 failed with error: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact. Retrying request in 11672 ms...
2024-05-21T02:15:27.1556076Z ##[error]Failed to CreateArtifact: Failed to make request after 5 attempts: Request timeout: /twirp/github.actions.results.api.v1.ArtifactService/CreateArtifact

Happened multiple times in the last week. I'm using ubuntu-latest runner. Example: https://github.com/smartcontractkit/chainlink/actions/runs/9167647126/job/25205269179

What did you expect to happen?

Artifacts should be successfully uploaded.

How can we reproduce it?

This is an issue that happens randomly

Anything else we need to know?

No response

What version of the action are you using?

v4.3.3

What are your runner environments?

linux

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

No response

NxPKG commented 6 months ago

Random failures in GitHub Actions when trying to upload artifacts can be frustrating, particularly when they result in timeouts after multiple attempts. Here are a few suggestions and steps you can take to mitigate this problem:

  1. Increase Timeout and Retry Logic:

    • The default retry logic might not be sufficient due to intermittent network issues or load on GitHub's servers. You could try to increase the timeout and retry logic if configurable.
  2. Check Network and Server Load:

    • Ensure that there are no network issues on your end. Sometimes, intermittent network problems can cause such issues.
    • Check GitHub's status page to ensure there are no ongoing incidents or maintenance activities.
  3. Use actions/upload-artifact:

    • Ensure you are using the latest version of the actions/upload-artifact. Sometimes, upgrading to the latest version can resolve underlying issues.
  4. Split Artifacts:

    • If you are uploading a large number of files or large files, consider splitting them into smaller chunks or separate artifacts.
  5. Custom Action with Enhanced Retry Logic:

    • If the problem persists, you might want to create a custom action with enhanced retry logic, including exponential backoff or increased number of retries.

Here is an example of how you can configure the actions/upload-artifact with additional context or custom retry logic:

name: Upload Artifacts with Retry Logic

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Build project
      run: |
        # Your build commands here
        echo "Building project..."

    - name: Upload artifacts with retry
      run: |
        for i in {1..5}; do
          if [ $i -gt 1 ]; then
            echo "Retry attempt $i"
            sleep $((i * 3))
          fi
          if gh api -X POST -F artifact='@artifact.zip' /repos/:owner/:repo/actions/artifacts | jq -e '.id'; then
            echo "Artifact uploaded successfully"
            break
          elif [ $i -eq 5 ]; then
            echo "Failed to upload artifact after $i attempts"
            exit 1
          fi
        done

    - name: Upload artifacts using action
      uses: actions/upload-artifact@v3
      with:
        name: my-artifact
        path: path/to/artifacts/

In the custom retry logic step, replace the gh api command with the actual command that uploads the artifact, and adjust the retry delay as needed.

Additional Tips:

carlcsaposs-canonical commented 5 months ago

Also seeing this, for example: https://github.com/canonical/postgresql-k8s-operator/actions/runs/9638014269/job/26578262353#step:22:16

Also seeing this on download-artifact: https://github.com/actions/download-artifact/issues/338

We're using the latest version of actions/upload-artifact and we're using ubuntu-latest runners (hosted by GitHub, we have no control over networking)

https://www.githubstatus.com/history shows no incidents when we encountered this issue

trihoang1 commented 3 months ago

I met the same issue on actions/upload-artifact@v4 image

stephen-carter-at-sf commented 3 months ago

I'm seeing this issue right now over at: https://github.com/forcedotcom/sfdx-scanner/actions/runs/10216682015/job/28268718086#step:11:19

--- Rerunning my workflow worked. So this seemed to just be a blip of sorts. https://github.com/forcedotcom/sfdx-scanner/actions/runs/10216830278

zanieb commented 1 month ago

I'm also seeing this frequently on v4, e.g. this run. It usually succeeds on retry. Is there any plan to have more robust retries in this action?

jsoref commented 3 weeks ago

For my reference, I hit this today: https://github.com/orgs/community/discussions/143089

marcodicro-dp commented 1 week ago

Same happening to me at the moment:

image
momentmaker commented 1 week ago

yep same here. could someone please take a look?

rwader-swi commented 4 days ago

same in my case. Atleast please don't deprecate v3