runatlantis / atlantis

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

0.23.5 attempts to autoplan a project even when autoplan is disabled. #3368

Open mrwacky42 opened 1 year ago

mrwacky42 commented 1 year ago

Community Note


Overview of the Issue

We just updated from 0.19.3 to 0.23.5, and a PR that changed two projects tried to make a plan for both, when the configuration indicates only one should autoplan.

Reproduction Steps

Open a PR with this config and changes to both directories, and see 2 plans instead of 1. (Except the project that should not plan is failing, which is why it is disabled.) Here's a config. For `$REASONS`, the `no-plan` project is disabled but present in our `atlantis.yaml`: ```yaml - name: no-plan autoplan: enabled: false dir: no/plan/dir workflow: workflow workspace: default apply_requirements: - approved - mergeable - name: plan-me-please autoplan: when_modified: - '**/*' - '!.terraform.lock.hcl' - '!**/*.md' dir: plan/me/please workflow: workflow workspace: prod apply_requirements: - mergeable ``` ### Logs The logs indicate the `when_modified` is the reason why both were planned: ``` {"level":"info","ts":"2023-05-02T16:03:27.205Z","caller":"events/project_command_builder.go:365","msg":"2 projects are to be planned based on their when_modified config","json":{"repo":"redacted","pull":"12835"}} ```

Environment details

Atlantis server-side config files:

config.yaml:

automerge: true
slack-token: REDACTED
webhooks:
- event: apply
  workspace-regex: .*
  kind: slack
  channel: deployment

(relevant parts of) repos.yaml:

repos:
- id: /.*/
  allowed_overrides: [workflow, apply_requirements]

workflows:

  workflow:
    plan:
      steps:
      - env:
          name: <REDACTED1>
          command: 'REDACTED1'

      - run: tfenv install
      - init:
          extra_args: ["-backend-config='role_arn=arn:aws:iam::<REDACTED>'"]
      - plan:
          extra_args: ["-var='terraform_exec_role=<REDACTED>'"]

Repo atlantis.yaml file: see above

Additional Context

None

nitrocode commented 1 year ago

@mrwacky42 if you have time, could you check previous versions and see which one was the last one that worked as expected? This will help identify the release that contained the issue

projects are to be planned based on their when_modified config

https://github.com/runatlantis/atlantis/blob/f033e86f17f6fefbad1cc8a7fdf9ea5d9ce5a00b/server/events/project_command_builder.go#L358-L369

According to the history of this file, the following prs were merged recently (in order of most recent)

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.'