Skip to content

no plan found after apply not mergeable #2483

Open
@macmiranda

Description

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

We have enabled the mergeable check for our repo on Github. Everything works fine in regards to that: requires an approval by a code owner and no merge conflicts. The problem arises when someone "accidentally" instructs Atlantis to apply the plan before the PR has been approved. Apply will fail with Apply Failed: Pull request must be approved by at least one person other than the author before running apply. which is expected. Upon approval, we try to apply again but this time we get the error no plan found at path "." and workspace "xxx"–did you run plan?, which we didn't expect since the plan hasn't changed. That forces us to run atlantis plan once more and then everything works fine.

Reproduction Steps

  • Make sure Atlantis is configured to require mergeable and approved PRs and autoplan is enabled
  • Create a PR with some dummy change in a .tf file
  • Atlantis will plan the PR for all the configured workspaces
  • Run atlantis apply -w <workspace> before the PR has been approved
  • Atlantis should not allow it to be applied
  • Approve the PR and make sure it is mergeable
  • Try to apply again. You should get the error no plan found at path "." and workspace "xxx"–did you run plan?

Logs

Logs
  |   | 2022-09-01 12:09:39 | {"level":"warn","ts":"2022-09-01T10:09:39.720Z","caller":"events/apply_command_runner.go:115","msg":"unable to get pull request status: fetching mergeability status for repo: apollon-fulfillment/terraform, and pull number: 273: fetching PR required checks: GET https://api.github.com/repos/apollon-fulfillment/terraform/branches/main/protection/required_status_checks: 403 Resource not accessible by integration []. Continuing with mergeable and approved assumed false","json":{"repo":"apollon-fulfillment/terraform","pull":"273"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:115\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:277"}
  |   | 2022-09-01 12:09:39 | {"level":"error","ts":"2022-09-01T10:09:39.720Z","caller":"vcs/instrumented_client.go:183","msg":"Unable to check pull mergeable status, error: fetching PR required checks: GET https://api.github.com/repos/apollon-fulfillment/terraform/branches/main/protection/required_status_checks: 403 Resource not accessible by integration []","json":{"repository":"apollon-fulfillment/terraform","pull-num":"273"},"stacktrace":"github.com/runatlantis/atlantis/server/events/vcs.(*InstrumentedClient).PullIsMergeable\n\tgithub.com/runatlantis/atlantis/server/events/vcs/instrumented_client.go:183\ngithub.com/runatlantis/atlantis/server/events/vcs.(*ClientProxy).PullIsMergeable\n\tgithub.com/runatlantis/atlantis/server/events/vcs/proxy.go:72\ngithub.com/runatlantis/atlantis/server/events/vcs.(*pullReqStatusFetcher).FetchPullStatus\n\tgithub.com/runatlantis/atlantis/server/events/vcs/pull_status_fetcher.go:28\ngithub.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:109\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:277"}
  |   | 2022-09-01 12:09:40 | {"level":"error","ts":"2022-09-01T10:09:40.639Z","caller":"events/instrumented_project_command_runner.go:49","msg":"Failure running apply operation: Pull request must be approved by at least one person other than the author before running apply.","json":{"repo":"apollon-fulfillment/terraform","pull":"273"},"stacktrace":"github.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:49\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Apply\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:21\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:47\ngithub.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:150\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:277"}
  |   | 2022-09-01 12:09:41 | {"level":"info","ts":"2022-09-01T10:09:41.762Z","caller":"events/automerger.go:20","msg":"not automerging because project at dir \".\", workspace \"platform\" has status \"apply_errored\"","json":{"repo":"apollon-fulfillment/terraform","pull":"273"}}
  |   | 2022-09-01 12:10:09 | {"level":"info","ts":"2022-09-01T10:10:09.190Z","caller":"events/events_controller.go:533","msg":"parsed comment as command=\"apply\" verbose=false dir=\"\" workspace=\"platform\" project=\"\" flags=\"\"","json":{"gh-request-id":"X-Github-Delivery=40921f30-29de-11ed-95d0-07e43d728939"}}
  |   | 2022-09-01 12:10:12 | {"level":"error","ts":"2022-09-01T10:10:12.065Z","caller":"events/instrumented_project_command_runner.go:43","msg":"Error running apply operation: no plan found at path \".\" and workspace \"platform\"–did you run plan?\n","json":{"repo":"apollon-fulfillment/terraform","pull":"273"},"stacktrace":"github.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:43\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Apply\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:21\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:47\ngithub.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:150\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:277"}
  |   | 2022-09-01 12:10:13 | {"level":"info","ts":"2022-09-01T10:10:13.338Z","caller":"events/automerger.go:20","msg":"not automerging because project at dir \".\", workspace \"platform\" has status \"apply_errored\"","json":{"repo":"apollon-fulfillment/terraform","pull":"273"}}
  |   | 2022-09-01 12:10:36 | {"level":"info","ts":"2022-09-01T10:10:36.770Z","caller":"events/events_controller.go:533","msg":"parsed comment as command=\"apply\" verbose=false dir=\"\" workspace=\"qa\" project=\"\" flags=\"\"","json":{"gh-request-id":"X-Github-Delivery=515c10a0-29de-11ed-8ee0-d0c7fbe5db65"}}
  |   | 2022-09-01 12:10:39 | {"level":"error","ts":"2022-09-01T10:10:39.506Z","caller":"events/instrumented_project_command_runner.go:43","msg":"Error running apply operation: no plan found at path \".\" and workspace \"qa\"–did you run plan?\n","json":{"repo":"apollon-fulfillment/terraform","pull":"273"},"stacktrace":"github.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:43\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Apply\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:21\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:47\ngithub.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:150\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:277"}

Environment details

If not already included, please provide the following:

  • Atlantis version: v0.19.5-pre.20220628
  • If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: no
  • Atlantis flags: see below

Atlantis server-side config file:

# running on ECS with the following environment variables:
custom_environment_variables = [{
  name  = "ATLANTIS_REPO_CONFIG_JSON"
  value = "{\"repos\":[{\"id\":\"/.*/\", \"apply_requirements\":[\"approved\", \"mergeable\"]}]}"
  }, {
  name  = "ATLANTIS_SLACK_TOKEN"
  value = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  }, {
  name  = "ATLANTIS_CONFIG"
  value = "/home/atlantis/config.yaml"
  }, {
  name  = "ATLANTIS_ALLOW_DRAFT_PRS"
  value = true
  }]

and config.yaml like:

log-level: debug
webhooks:
- event: apply
  workspace-regex: .*
  kind: slack
  channel: atlantis-apply

Repo atlantis.yaml file:

# config file
version: 3
automerge: true
parallel_plan: false
parallel_apply: false
projects:
- dir: .
  workspace: platform
  autoplan:
    enabled: true
  terraform_version: v1.1.9
- dir: .
  workspace: qa
  autoplan:
    enabled: true
  terraform_version: v1.1.9
- dir: .
  workspace: staging
  autoplan:
    enabled: true
  terraform_version: v1.1.9
- dir: .
  workspace: production
  autoplan:
    enabled: true
  terraform_version: v1.1.9

Additional Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedGood feature for contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions