NETWAYS / ansible-collection-elasticstack

A collection to install and manage the Elastic Stack
GNU General Public License v3.0
11 stars 9 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.

widhalmt commented 1 month ago

@afeefghannam89 since we improved our checks by a lot, do you still think, this is necessary?

afeefghannam89 commented 1 month ago

When the Pipeline do not fail anymore, we do not need it. I find the possible solution not optimal, what do you think? If you see the same, you can close this issue, thanks.