runatlantis / atlantis

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

References for commit Not Found #2606

Open theautoroboto opened 2 years ago

theautoroboto commented 2 years ago

Community Note


Overview of the Issue

When attempting an atlantis apply in a PR from a fork, the process fails with Error: goroutine panic. This is a bug.

Reproduction Steps

Verify environment variable has been set -- ATLANTIS_ALLOW_FORK_PRS=true Fork Repo Make a change Submit a PR run atlantis apply

Logs

Log posted to GitLab PR Error: goroutine panic. This is a bug.

runtime error: invalid memory address or nil pointer dereference
runtime/panic.go:260 (0x44c995)
runtime/signal_unix.go:835 (0x44c965)
github.com/runatlantis/atlantis/server/events/vcs/gitlab_client.go:209 (0xb8f5fa)
github.com/runatlantis/atlantis/server/events/vcs/proxy.go:72 (0xb947c4)
github.com/runatlantis/atlantis/server/events/vcs/pull_status_fetcher.go:28 (0xb95045)
github.com/runatlantis/atlantis/server/events/apply_command_runner.go:108 (0xd74c15)
github.com/runatlantis/atlantis/server/events/command_runner.go:296 (0xd79823)
runtime/asm_amd64.s:1594 (0x467ca0)

Logs from pod

{"level":"warn","ts":"2022-10-20T13:31:20.736Z","caller":"events/apply_command_runner.go:100","msg":"unable to update commit status: POST https://xxx/api/v4/projects/bsmith/runatlantis-terraform/statuses/d670fed43f6ff5e5ef7fc2dffe5ca86f61dd839d: 404 {message: 404 References for commit Not Found}","json":{"repo":"bsmith/runatlantis-terraform","pull":"14"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:100\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:296"}
{"level":"error","ts":"2022-10-20T13:31:20.936Z","caller":"events/command_runner.go:427","msg":"PANIC: runtime error: invalid memory address or nil pointer dereference\nruntime/panic.go:260 (0x44c995)\nruntime/signal_unix.go:835 (0x44c965)\ngithub.com/runatlantis/atlantis/server/events/vcs/gitlab_client.go:209 (0xb8f5fa)\ngithub.com/runatlantis/atlantis/server/events/vcs/proxy.go:72 (0xb947c4)\ngithub.com/runatlantis/atlantis/server/events/vcs/pull_status_fetcher.go:28 (0xb95045)\ngithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:108 (0xd74c15)\ngithub.com/runatlantis/atlantis/server/events/command_runner.go:296 (0xd79823)\nruntime/asm_amd64.s:1594 (0x467ca0)\n","json":{"repo":"bsmith/runatlantis-terraform","pull":"14"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).logPanics\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:427\nruntime.gopanic\n\truntime/panic.go:890\nruntime.panicmem\n\truntime/panic.go:260\nruntime.sigpanic\n\truntime/signal_unix.go:835\ngithub.com/runatlantis/atlantis/server/events/vcs.(*GitlabClient).PullIsMergeable\n\tgithub.com/runatlantis/atlantis/server/events/vcs/gitlab_client.go:209\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:108\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:296"}

Environment details

If not already included, please provide the following:

michelmzs commented 2 years ago

Can you share the GitLab version where it occurred?

Probably related to https://github.com/runatlantis/atlantis/issues/2484

theautoroboto commented 2 years ago

We are running GitLab Community Edition [15.2.3]

michelmzs commented 2 years ago

@theautoroboto I haven't found a way to relate the Atlantis commit status to the MR from the fork branch. Maybe it's a limitation of GitLab, we need to test more. As another option, you can define a simple job in .gitlab-ci.yml to be triggered on MRs, this creates a pipeline ID and allows the Atlantis to successfully apply.