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

fix: Pre Workflow Hook VCS Combined Status Check Set to Pending Twice #5242

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented Jan 17, 2025

what

Fix the VCS combined status check from being set to pending twice when pre-workflow hooks are configured.

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

why

  • Removes status check update failure message from log.

tests

Logs Before
{"level":"info","ts":"2025-01-26T18:04:31.129Z","caller":"events/events_controller.go:692","msg":"Handling 'plan' comment","json":{"repo":"sheather/test","pull":31}}
{"level":"info","ts":"2025-01-26T18:04:32.285Z","caller":"events/events_controller.go:736","msg":"Running comment command 'plan' for user 'sheather'.","json":{"repo":"sheather/test","pull":31}}
{"level":"info","ts":"2025-01-26T18:04:33.538Z","caller":"events/pre_workflow_hooks_command_runner.go:53","msg":"Pre-workflow hooks configured, running...","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:04:33.579Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/plan' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:04:33.740Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:04:33.933Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/pre_workflow_hook: Atlantis Setup' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:04:34.225Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:05:04.812Z","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":"2025-01-26T18:05:04.812Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/pre_workflow_hook: Atlantis Setup' to 'success'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:05:04.908Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:05:05.142Z","caller":"events/pre_workflow_hooks_command_runner.go:103","msg":"Pre-workflow hooks completed successfully","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:05:06.265Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/plan' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:05:06.394Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"warn","ts":"2025-01-26T18:05:06.621Z","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\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\t/mnt/c/Users/Simon/Documents/GitHub/X-Guardian/atlantis/server/events/plan_command_runner.go:307\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\t/mnt/c/Users/Simon/Documents/GitHub/X-Guardian/atlantis/server/events/command_runner.go:383"}
Logs After
{"level":"info","ts":"2025-01-26T18:15:09.044Z","caller":"events/events_controller.go:692","msg":"Handling 'plan' comment","json":{"repo":"sheather/test","pull":31}}
{"level":"info","ts":"2025-01-26T18:15:09.605Z","caller":"events/events_controller.go:736","msg":"Running comment command 'plan' for user 'sheather'.","json":{"repo":"sheather/test","pull":31}}
{"level":"info","ts":"2025-01-26T18:15:10.520Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/plan' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:10.807Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:11.100Z","caller":"events/pre_workflow_hooks_command_runner.go:53","msg":"Pre-workflow hooks configured, running...","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:11.115Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/pre_workflow_hook: Atlantis Setup' to 'running'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:11.822Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:42.359Z","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":"2025-01-26T18:15:42.360Z","caller":"vcs/gitlab_client.go:411","msg":"Updating GitLab commit status for 'atlantis/pre_workflow_hook: Atlantis Setup' to 'success'","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:42.464Z","caller":"vcs/gitlab_client.go:436","msg":"Pipeline found for commit a1e2908f540bd9e0b9beb57ace6ebbdecf57bc9b, setting pipeline ID to 100","json":{"repo":"sheather/test","pull":"31"}}
{"level":"info","ts":"2025-01-26T18:15:42.674Z","caller":"events/pre_workflow_hooks_command_runner.go:91","msg":"Pre-workflow hooks completed successfully","json":{"repo":"sheather/test","pull":"31"}}

references

@X-Guardian X-Guardian marked this pull request as ready for review January 26, 2025 18:24
@X-Guardian X-Guardian requested review from a team as code owners January 26, 2025 18:24
@X-Guardian X-Guardian requested review from GenPage, lukemassa and nitrocode and removed request for a team January 26, 2025 18:25
@dosubot dosubot bot added bug Something isn't working go Pull requests that update Go code labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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