nick-fields / retry

Retries a GitHub Action step on failure or timeout
MIT License
427 stars 83 forks source link

Provide a way to randomize retry times #141

Open sethgupton-mastery opened 1 month ago

sethgupton-mastery commented 1 month ago

Describe the bug We have a thundering herd problem where a bunch of workflows come in at the same time and need to commit to the same file. They all come in, one succeeds and the rest fail, they wait for retry_wait_seconds, one more succeeds and the rest fail... Repeat until only max_attempts succeeds and the rest fail.

Expected behavior Add ability to add some randomness to the retry_wait_seconds.

sethgupton-mastery commented 1 month ago

P.S. We are solving this in a different way right now. But it would be nice to have it built in.

- name: Generate random retry_wait_seconds
  id: randomize-retry
  run: |          
   random_retry_wait=$((5 + RANDOM % 16))
   echo "Random retry wait time: $random_retry_wait seconds"
   echo "retry_wait_seconds=$random_retry_wait" >> $GITHUB_ENV

- name: Commit updates
  uses: nick-fields/retry@v2.8.3
  with:
   timeout_minutes: 2
   retry_on: any
   retry_wait_seconds: ${{ env.retry_wait_seconds }}
   max_attempts: 10
   command: |