runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.82k stars 1.06k forks source link

Rerunning a plan or running an apply should set `atlantis/post_workflow_hook` to `pending` #3007

Open nitrocode opened 1 year ago

nitrocode commented 1 year ago

Community Note


Overview of the Issue

Rerunning a plan or running an apply should set atlantis/post_workflow_hook to pending

This issue may also affect atlantis/pre_workflow_run

Reproduction Steps

  1. Open a PR
  2. Run atlantis plan
  3. Rerun atlantis plan
  4. Notice that the atlantis/post_workflow_hook is stuck in "succeeded" instead of going to "pending"

Logs

N/A

Environment details

Atlantis server-side config file:

repos:
  - id: /.*/
    apply_requirements:
      - mergeable
      - approved
    workflow: terraform
    post_workflow_hooks:
      - run: |
          echo "Post workflow run completed successfully"

Additional Context

The only way to know it is a different run is due to the job id changing in the URL.

Fabianoshz commented 1 year ago

Hi @nitrocode, I tried to reproduce this and I got this behaviour:

If your pre/post workflow hooks are being executed really fast (like when using an echo) you're not going to see the status being updated to pending because github (or other VCS client) will receive 2 updates in a very short time. You can test using a sleep command.

What we can do is to change the current implementation to reset every pre/post workflow even before running the received command, this would set every workflow to pending even before running the first command.