vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.69k stars 411 forks source link

Implement retry logic in Docker workflow to handle network failures #374

Closed ThomasSanson closed 1 month ago

ThomasSanson commented 1 year ago

Hello,

We have been experiencing occasional failures in our Docker GitHub Actions workflow due to network issues. These failures usually occur in the "Run Docker tests" steps of the workflow.

To mitigate this, I would like to implement a retry mechanism in our workflow. The idea is to retry these steps a few times (let's say 3 times) before marking the workflow as failed. This should help us handle transient network issues.

Considering using the nick-invision/retry@v2 action for this, which would modify our workflow file to look like this:

name: "Docker"

on:  
  push:  
    branches:  
    - master  
  pull_request:  
    branches:  
    - master  

jobs:  
  build:  
    runs-on: ubuntu-latest  
    steps:  
    - name: Set TERM environment variable  
      run: echo "TERM=xterm" >> $GITHUB_ENV  

    - name: Checkout  
      uses: actions/checkout@v3  

    - name: Set up Python 3.10  
      uses: actions/setup-python@v4  
      with:  
        python-version: "3.10"  

    - name: Install dependencies  
       run: make bootstrap-dev  

    - name: Run Docker tests  
      uses: nick-invision/retry@v2
      with:
        max_attempts: 3
        timeout_minutes: 10
        command: make docker-tests

https://github.com/vitabaks/postgresql_cluster/actions/runs/5224946567/jobs/9433782895?pr=373#step:6:999