NETWAYS / ansible-collection-elasticstack

A collection to install and manage the Elastic Stack
GNU General Public License v3.0
10 stars 8 forks source link

Rerun pipeline automatically if it fails #195

Open afeefghannam89 opened 1 year ago

afeefghannam89 commented 1 year ago

We should see the ability to re-run failed full stack pipelines automatically if they are not ended successfully. The retry times is also important.

widhalmt commented 1 year ago

Honestly, I didn't know that was possible. It would be a great addition nowadays. Especially if we could have some time between failing and rerunning.

Donien commented 1 year ago

From what I could find (and according to this blog post) our only options seem to be

The latter offers timeout_minutes and max_attempts which would pretty much achieve what we are trying to do.

So in .github/workflows/test_full_stack.yml we could do something like this:

...
      - name: Test with molecule
        uses: nick-fields/retry@v2
        with:
          timeout_minutes: 10
          max_attempts: 3
          command: molecule test -s ${{ matrix.scenario }}
        env:
          MOLECULE_DISTRO: ${{ matrix.distro }}
          PY_COLORS: '1' 
          ANSIBLE_FORCE_COLOR: '1' 
          ELASTIC_RELEASE: ${{ matrix.release }}
...

Going for the first option, it could look like this:

...
      - name: Test with molecule
        id: firsttry
        continue-on-error: true
        run: |
          molecule test -s ${{ matrix.scenario }}
        env:
          MOLECULE_DISTRO: ${{ matrix.distro }}
          PY_COLORS: '1'
          ANSIBLE_FORCE_COLOR: '1'
          ELASTIC_RELEASE: ${{ matrix.release }}

      - name: Test with molecule
        id: secondtry
        if: steps.firsttry.outcome == 'failure'
        run: |
          sleep 60
          molecule test -s ${{ matrix.scenario }}
        env:
          MOLECULE_DISTRO: ${{ matrix.distro }}
          PY_COLORS: '1'
          ANSIBLE_FORCE_COLOR: '1'
          ELASTIC_RELEASE: ${{ matrix.release }}
...

Depending on the amount of retries we desire we'd need to add as many steps to the job.


Rerunning a whole workflow does not seem possible at the moment.