runatlantis / atlantis

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

atlantis apply not working #4700

Open HK78-HAHA opened 1 week ago

HK78-HAHA commented 1 week ago

Community Note


Overview of the Issue

At some point atlantis was working fine, but now when I run the atlantis apply command on a particular repo, it doesn't work. I've looked at both server-side and repo-level configurations, I've looked at the logs of the pods atlantis is running on, and at the end of the day I don't know what's causing it, so I'm attaching the symptoms and the setup information of the server/repo.

atlantis_error1

Reproduction Steps

For prex-terraform, atlantis apply runs fine with no issues, and the problem occurs on prex-terraform-cloudflare.

Logs

atlantis server(pod) logs

{"level":"info","ts":"2024-06-24T11:48:47.194Z","caller":"events/events_controller.go:550","msg":"parsed comment as command=\"apply\" verbose=false dir=\"\" workspace=\"\" project=\"\" policyset=\"\", clear-policy-approval=false, flags=\"\"","json":{"gh-request-id":"X-Github-Delivery=b65c9330-321f-11ef-9bec-7b2b3433cde6"}}
{"level":"info","ts":"2024-06-24T11:48:47.706Z","caller":"events/events_controller.go:593","msg":"Running comment command 'apply' on repo 'teamprex/prex-terraform-cloudflare', pull request: 32 for user 'hyunjong-prestolabs'.","json":{"gh-request-id":"X-Github-Delivery=b65c9330-321f-11ef-9bec-7b2b3433cde6"}}
{"level":"info","ts":"2024-06-24T11:48:48.134Z","caller":"vcs/instrumented_client.go:236","msg":"updating vcs status","json":{"repository":"teamprex/prex-terraform-cloudflare","pull-num":"32","src":"atlantis/apply","description":"Apply in progress...","state":"pending","url":""}}
{"level":"info","ts":"2024-06-24T11:48:50.175Z","caller":"vcs/instrumented_client.go:236","msg":"updating vcs status","json":{"repository":"teamprex/prex-terraform-cloudflare","pull-num":"32","src":"atlantis/apply","description":"0/1 projects applied successfully.","state":"failed","url":""}}
{"level":"info","ts":"2024-06-24T11:49:22.386Z","caller":"events/events_controller.go:550","msg":"parsed comment as command=\"apply\" verbose=false dir=\"\" workspace=\"\" project=\"flipster.io\" policyset=\"\", clear-policy-approval=false, flags=\"\"","json":{"gh-request-id":"X-Github-Delivery=cb8c9de0-321f-11ef-9c0b-7c2536609ca5"}}
{"level":"info","ts":"2024-06-24T11:49:22.800Z","caller":"events/events_controller.go:593","msg":"Running comment command 'apply' on repo 'teamprex/prex-terraform-cloudflare', pull request: 32 for user 'hyunjong-prestolabs'.","json":{"gh-request-id":"X-Github-Delivery=cb8c9de0-321f-11ef-9c0b-7c2536609ca5"}}
{"level":"info","ts":"2024-06-24T11:49:23.277Z","caller":"vcs/instrumented_client.go:236","msg":"updating vcs status","json":{"repository":"teamprex/prex-terraform-cloudflare","pull-num":"32","src":"atlantis/apply","description":"Apply in progress...","state":"pending","url":""}}
{"level":"info","ts":"2024-06-24T11:49:24.628Z","caller":"vcs/instrumented_client.go:236","msg":"updating vcs status","json":{"repository":"teamprex/prex-terraform-cloudflare","pull-num":"32","src":"atlantis/apply: flipster.io","description":"Apply in progress...","state":"pending","url":"https://atlantis.flipster.co/jobs/32022f54-1d78-4574-a31b-6c30ee9826c0"}}
{"level":"info","ts":"2024-06-24T11:49:25.028Z","caller":"vcs/instrumented_client.go:236","msg":"updating vcs status","json":{"repository":"teamprex/prex-terraform-cloudflare","pull-num":"32","src":"atlantis/apply: flipster.io","description":"Apply failed.","state":"failed","url":"https://atlantis.flipster.co/jobs/32022f54-1d78-4574-a31b-6c30ee9826c0"}}
{"level":"error","ts":"2024-06-24T11:49:25.438Z","caller":"events/instrumented_project_command_runner.go:78","msg":"Error running apply operation: no plan found at path \"flipster.io\" and workspace \"default\"–did you run plan?\n","json":{"repo":"teamprex/prex-terraform-cloudflare","pull":"32"},"stacktrace":"github.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:78\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Apply\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:46\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:48\ngithub.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:166\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:365"}
{"level":"info","ts":"2024-06-24T11:49:26.085Z","caller":"vcs/instrumented_client.go:236","msg":"updating vcs status","json":{"repository":"teamprex/prex-terraform-cloudflare","pull-num":"32","src":"atlantis/apply","description":"0/1 projects applied successfully.","state":"failed","url":""}}

Environment details

For prex-terraform, atlantis apply runs fine with no issues, and the problem occurs on prex-terraform-cloudflare.

Atlantis server-side config file:

repos:
 - id: github.com/teamprex/prex-terraform
   apply_requirements: [approved]
   workflow: default
   allowed_overrides: [workflow]
   allow_custom_workflows: true
 - id: github.com/teamprex/prex-terraform-cloudflare
   apply_requirements: [approved]
   workflow: default
   allowed_overrides: [workflow]
   allow_custom_workflows: true
 workflows:
   default:
     plan:
       steps: [init, plan]
     apply:
       steps: [apply]

Repo atlantis.yaml file:

version: 3
automerge: false
projects:
  - name: flipster.io
    dir: flipster.io/
    terraform_version: v1.6.3
    workflow: default
    autoplan:
      when_modified: ["*.tf", "./yaml/*.yaml"]
  - name: flipster.xyz
    dir: flipster.xyz/
    terraform_version: v1.6.3
    workflow: default
    autoplan:
      when_modified: ["*.tf", "./yaml/*.yaml"]
workflows:
  default:
    plan:
      steps:
        - init
        - run: terraform plan > ./planfile && sed '/^~ {/,/^\s*}/d' ./planfile | sed '/-> (known after apply)/d' | python3 -c "import re, sys; print(re.sub(r'\s*~ rules \{\s*# \(.*?unchanged attributes hidden\)\s*# \(.*?unchanged block hidden\)\s*\}', '', sys.stdin.read(), flags=re.DOTALL))" && rm ./planfile
    apply:
      steps:
        - apply

Additional Context