runatlantis / atlantis

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

atlantis server `--hide-unchanged-plan-comments` option broken on version 0.23.2 #3234

Open srinivasaluka opened 1 year ago

srinivasaluka commented 1 year ago

Hi,

I'm using Atlantis version 0.23.2 for running terragrunt plan to see the plan output as bitbucket cloud pull request comment. Below is the serverside repos.yaml file::

repos:
- id: "/.*/"
  allowed_overrides: [workflow]
  allow_custom_workflows: true
  workflow: terragrunt
workflows:
  terragrunt:
    plan:
      steps:
      - env:
          name: GOOGLE_APPLICATION_CREDENTIALS
          command: 'echo "$GOOGLE_APPLICATION_CREDENTIALS"'
      - env:
          name: TERRAGRUNT_TFPATH
          command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
      - run: ls
      - run: cp -rf ../_templates_final/* .
      - run: export TF_CLI_ARGS_plan="-compact-warnings"
      - run: terragrunt run-all plan --terragrunt-non-interactive --terragrunt-ignore-external-dependencies --terragrunt-parallelism 10 -no-color
#####################################################

when i pass the repos.yaml file for Atlantis version v0.20.1 works fine and able to see the plan output as expected in the pull request. I have a lot of terraform modules and the output is too noisy, for this reason I switced to v0.23.2 and passed the flag --hide-unchanged-plan-comments while starting the atlantis server. There are errors in the output(probably git pull issue) with atlantis plan and we are unable to see the output in the PR.

Error:

checking if workspace exists: stat /home/atlantis/.atlantis/repos/mysoftware/my-infrastructure/314/default: no such file or directory

Log:

WARNING: Flag --disable-apply has been deprecated.
Create a --repo-config file with the following config instead:

---
repos:
- id: /.*/

or use --repo-config-json='{"repos":[{"id":"/.*/"}]}'

{"level":"warn","ts":"2023-03-07T10:10:47.575Z","caller":"cmd/server.go:1027","msg":"Bitbucket Cloud does not support webhook secrets. This could allow attackers to spoof requests from Bitbucket. Ensure you are allowing only Bitbucket IPs","json":{},"stacktrace":"github.com/runatlantis/atlantis/cmd.(*ServerCmd).securityWarnings\n\tgithub.com/runatlantis/atlantis/cmd/server.go:1027\ngithub.com/runatlantis/atlantis/cmd.(*ServerCmd).run\n\tgithub.com/runatlantis/atlantis/cmd/server.go:748\ngithub.com/runatlantis/atlantis/cmd.(*ServerCmd).Init.func2\n\tgithub.com/runatlantis/atlantis/cmd/server.go:640\ngithub.com/runatlantis/atlantis/cmd.(*ServerCmd).withErrPrint.func1\n\tgithub.com/runatlantis/atlantis/cmd/server.go:1108\ngithub.com/spf13/cobra.(*Command).execute\n\tgithub.com/spf13/cobra@v1.6.1/command.go:916\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\tgithub.com/spf13/cobra@v1.6.1/command.go:1044\ngithub.com/spf13/cobra.(*Command).Execute\n\tgithub.com/spf13/cobra@v1.6.1/command.go:968\ngithub.com/runatlantis/atlantis/cmd.Execute\n\tgithub.com/runatlantis/atlantis/cmd/root.go:30\nmain.main\n\tgithub.com/runatlantis/atlantis/main.go:66\nruntime.main\n\truntime/proc.go:250"}
{"level":"info","ts":"2023-03-07T10:10:48.104Z","caller":"server/server.go:440","msg":"Utilizing BoltDB","json":{}}
{"level":"info","ts":"2023-03-07T10:10:48.115Z","caller":"server/server.go:955","msg":"Atlantis started - listening on port 4141","json":{}}
{"level":"info","ts":"2023-03-07T10:10:48.116Z","caller":"scheduled/executor_service.go:47","msg":"Scheduled Executor Service started","json":{}}
{"level":"info","ts":"2023-03-07T10:13:12.621Z","caller":"events/events_controller.go:545","msg":"parsed comment as command=\"plan\" verbose=false dir=\"projects/my-devenv-1\" workspace=\"\" project=\"\" flags=\"\"","json":{}}
{"level":"warn","ts":"2023-03-07T10:13:14.653Z","caller":"events/plan_command_runner.go:190","msg":"unable to update commit status: making request \"POST https://api.bitbucket.org/2.0/repositories/mysoftware/my-infrastructure/commit/ff61bed3a67c/statuses/build\" unexpected status code: 400, body: {\"type\": \"error\", \"error\": {\"message\": \"url: Enter a valid URL.\", \"fields\": {\"url\": [\"Enter a valid URL.\"]}}}","json":{"repo":"mysoftware/my-infrastructure","pull":"301"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:190\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:290\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:296"}
{"level":"error","ts":"2023-03-07T10:13:14.654Z","caller":"events/instrumented_project_command_builder.go:75","msg":"Error building plan commands: checking if workspace exists: stat /home/atlantis/.atlantis/repos/mysoftware/my-infrastructure/301/default: no such file or directory","json":{},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandBuilder).buildAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_builder.go:75\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandBuilder).BuildPlanCommands\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_builder.go:35\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:193\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:290\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:296"}
{"level":"warn","ts":"2023-03-07T10:13:14.934Z","caller":"events/plan_command_runner.go:196","msg":"unable to update commit status: making request \"POST https://api.bitbucket.org/2.0/repositories/mysoftware/my-infrastructure/commit/ff61bed3a67c/statuses/build\" unexpected status code: 400, body: {\"type\": \"error\", \"error\": {\"message\": \"url: Enter a valid URL.\", \"fields\": {\"url\": [\"Enter a valid URL.\"]}}}","json":{"repo":"mysoftware/my-infrastructure","pull":"301"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:196\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:290\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:296"}
{"level":"error","ts":"2023-03-07T10:13:14.935Z","caller":"events/pull_updater.go:17","msg":"checking if workspace exists: stat /home/atlantis/.atlantis/repos/mysoftware/my-infrastructure/301/default: no such file or directory","json":{"repo":"mysoftware/my-infrastructure","pull":"301"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*PullUpdater).updatePull\n\tgithub.com/runatlantis/atlantis/server/events/pull_updater.go:17\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:198\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:290\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:296"}

Please suggest

Thanks, Srinivas Aluka

nitrocode commented 1 year ago

That's odd. It works correctly in github. Could you incrementally go up from v0.20.1 to find the version that broken this functionality? You can get even more granular with the pre releases.

wyrie commented 1 year ago

I have the issue on v0.22.3 using Gitlab. Any ideas on how I can troubleshoot?

nitrocode commented 1 year ago

Please feel free to downgrade incrementally to find which pre release it worked in last so we can identify the pr that broke this functionality

nitrocode commented 1 year ago

I don't think this feature ever worked for gitlab tho

I checked and this was never implemented for gitlab.

srinivasaluka commented 1 year ago

Hi @nitrocode , In which version was this flag --hide-unchanged-plan-comments got added ?

jamengual commented 1 year ago

https://github.com/runatlantis/atlantis/pull/3158 @tufitko

tufitko commented 1 year ago

Hmm, @srinivasaluka why are you using run-all? Can you check any plan's output without --hide-unchanged-plan-comments flag? Do you see No changes... line?

tufitko commented 1 year ago

Also, you have one project for all repo or you use terragrunt-atlantis-config and create projects per module?

tufitko commented 1 year ago

I think the problem with run-all, is because any dependent module without changes prints No changes... and all plan hides

srinivasaluka commented 1 year ago

Hi @tufitko, my terraform modules are in a different repository and my terragrunt.hcl file is in different repo. I have one project for all repo, not creating projects per module

srinivasaluka commented 1 year ago

@tufitko run-all as we have 40+ terraform modules

tufitko commented 1 year ago

--hide-unchanged-plan-comments hides projects which has No changes in any lines, so you can't use it, because you have only one project. It doesn't modify the project's output.

did you see terragrunt-atlantis-config? why don't use it? I can show you my config if you need

about no such file or directory error I'm not sure, this flag doesn't work with files

andyshinn commented 1 year ago

Just want to echo that I upgraded to 0.23.2 and tried this feature and also got the checking if workspace exists: stat /home/atlantis/.atlantis/repos/mysoftware/my-infrastructure/314/default: no such file or directory error after enabling it. Unfortunately, we had to revert to a older 0.20 version again since there are still too many bugs present in later versions.

jamengual commented 1 year ago

we reverted 2 PR that caused issues, did you try v0.23.4? what other bugs you are referring to?

cilindrox commented 9 months ago

Seeing this on GitHub too. v0.27, running different projects. Dunno if related, but there was a recent GUI change on GH, where now you have to specify a reason for hiding a comment. Maybe the API endpoint now requires a different payload?