-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Gitlab v4 api 404 errors on commit status update - Wrong URLs vs. API spec? #4313
Comments
Issue #2685 also makes suggestions of a change to the gitlab API's around statuses so this might be a duplicate or related problem? |
We have a similar issue. Started happening when upgrading from v0.28.5 to v0.29.0 Here are our logs
|
We are experiencing the same problem with GitLab and version 0.29.0. Strangely, everything works if we open a new merge request (and close the old one beforehand). Is this also the case for you @Jonomir In our case, pre_workflow_hook_runner.go only triggers local commands why atlantis checks the gitlab api in that state? I found #2685 (comment) what could explain the error with 'fail-on-pre-workflow-hook-error' set, there is also no feedback to the gitlab comments logs {
"level": "warn",
"ts": "2024-09-27T11:20:54.828Z",
"caller": "events/pre_workflow_hooks_command_runner.go:76",
"msg": "unable to update plan commit status: 404 Not Found",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
},
"stacktrace": "github.com/runatlantis/atlantis/server/events.(*DefaultPreWorkflowHooksCommandRunner).RunPreHooks\n\tgithub.com/runatlantis/atlantis/server/events/pre_workflow_hooks_command_runner.go:76\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:339"
}
{
"level": "warn",
"ts": "2024-09-27T11:20:55.513Z",
"caller": "events/pre_workflow_hooks_command_runner.go:144",
"msg": "unable to update pre workflow hook status: 404 Not Found",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
},
"stacktrace": "github.com/runatlantis/atlantis/server/events.(*DefaultPreWorkflowHooksCommandRunner).runHooks\n\tgithub.com/runatlantis/atlantis/server/events/pre_workflow_hooks_command_runner.go:144\ngithub.com/runatlantis/atlantis/server/events.(*DefaultPreWorkflowHooksCommandRunner).RunPreHooks\n\tgithub.com/runatlantis/atlantis/server/events/pre_workflow_hooks_command_runner.go:84\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:339"
}
{
"level": "info",
"ts": "2024-09-27T11:20:55.513Z",
"caller": "events/pre_workflow_hooks_command_runner.go:145",
"msg": "is api? false",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
}
}
{
"level": "info",
"ts": "2024-09-27T11:20:55.513Z",
"caller": "events/pre_workflow_hooks_command_runner.go:147",
"msg": "is api? false",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
}
}
{
"level": "error",
"ts": "2024-09-27T11:20:55.513Z",
"caller": "events/command_runner.go:342",
"msg": "Error running pre-workflow hooks 404 Not Found.",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
},
"stacktrace": "github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:342"
}
{
"level": "error",
"ts": "2024-09-27T11:20:55.513Z",
"caller": "events/command_runner.go:345",
"msg": "'fail-on-pre-workflow-hook-error' set, so not running plan command.",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
},
"stacktrace": "github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:345"
}
{
"level": "warn",
"ts": "2024-09-27T11:20:56.432Z",
"caller": "events/command_runner.go:351",
"msg": "unable to update plan commit status: 404 Not Found",
"json": {
"repo": "/my/repo-obfuscate",
"pull": "62"
},
"stacktrace": "github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:351"
} |
I had this problem, I couldn't find a solution. I rolled back to v0.28.5 of atlantis for the moment. I would appreciate if there is any update on the bug. GitLab Premium 17.7 |
Got the same issue as @fede-r1c0 has. I spent a day trying to understand what was wrong until I came to this thread. And after downgrading to v0.28.5 - all ok. |
I may have found a workaround: We added a noop job in GitLab. Since we have more than just the external pipelines from Atlantis, it looks like this resolved the issue with the spinning pipeline status. We were wondering why another Atlantis repository never failed, and it turned out it had local linters configured, etc.
stages:
- noop
empty_job:
stage: noop
script:
- echo "This job does nothing but atlantis runs into 404 https://github.com/runatlantis/atlantis/issues/4313" |
Hah... it helped, @matzegebbe... Much appreciate. So, there should be either a real pipeline or a placeholder (like you suggested). |
It seems this (#5033) PR is supposed to fix this issue. |
Community Note
Overview of the Issue
I'm not absolutely sure if this is an issue with my config, with atlantis, or the underlying xanzy/go-gitlab module. I could be mistaken on any aspect of this as it's my first foray into Atlantis, and I have had a hard time making it work with the age of the infrastructure and code I am trying to make it work with.
Pointing Atlantis at a modern gitlab installation using API v4 fails consistently on the commit status updates.
I believe it is because the URL form used in the API calls that Atlantis makes against gitlab to update commit/MR statuses is incorrectly formed.
I've ruled out authorisation, project name escaping, and other possible trouble spots, I've even asked gitlab support and they concur with my assessment that atlantis is hitting the wrong URLs.
My client is extremely security sensitive so I have had to redact all this heavily, but I think you get the gist from the URL structure in the logs.
Compare with the gitlab v4 API specification: https://docs.gitlab.com/ee/api/commits.html#commit-status
Because I can't rule out that the failure to update the git status makes atlantis grind to a halt I can't be sure that my pre workflow hooks are at fault either. And there is no debugging output of the pre-workflow hooks that I could find which makes debugging much harder than it might otherwise be.
Also the debug output of Atlantis does not necessarily seem to reflect exactly what the underlying xanzy/go-gitlab module is actually hitting, down to the HTTP request method level, which made things harder still.
Reproduction Steps
Push any old gitlab MR at a gitlab v4 API instance connected to atlantis. Doesn't seem to matter the content.
Logs
Mar 05 12:48:02 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:02.726Z","caller":"events/working_dir.go:330","msg":"ran: git clone --depth=1 --branch BAU-test-commit-hook --single-branch https://MYATLANTISUSER:@MYGITLABSERVER.MYDOMAIN.COM/MYORG/MYPROJECT.git /home/atlantis/.atlantis/repos/MYORG/MYPROJECT/270/default. Output: Cloning into '/home/atlantis/.atlantis/repos/MYORG/MYPROJECT/270/default'...","json":{}}
Mar 05 12:48:02 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:02.727Z","caller":"events/pre_workflow_hooks_command_runner.go:121","msg":"Processing pre workflow hook 'Initialise git submodules before atlantis starts the terraform init otherwise it breaks.', Command 'plan', Target commands [plan]","json":{"repo":"MYORG/MYPROJECT","pull":"270"}}
Mar 05 12:48:02 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:02.727Z","caller":"events/pre_workflow_hooks_command_runner.go:129","msg":"Running pre workflow hook: 'Initialise git submodules before atlantis starts the terraform init otherwise it breaks.'","json":{"repo":"MYORG/MYPROJECT","pull":"270"}}
Mar 05 12:48:02 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:02.974Z","caller":"vcs/gitlab_client.go:442","msg":"GET /projects/MYORG/MYPROJECT/merge_requests/270 returned: 200","json":{}}
Mar 05 12:48:02 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:02.974Z","caller":"vcs/gitlab_client.go:411","msg":"Head pipeline found for merge request 270, source 'external'. refTarget 'BAU-test-commit-hook'","json":{}}
Mar 05 12:48:03 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:03.064Z","caller":"vcs/gitlab_client.go:434","msg":"POST /projects/MYORG/MYPROJECT/statuses/e18a4852a5fa74d2bae3cf8afa6d6e19REDACTED returned: 404","json":{}}
Mar 05 12:48:03 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"warn","ts":"2024-03-05T12:48:03.064Z","caller":"events/pre_workflow_hooks_command_runner.go:147","msg":"unable to update pre workflow hook status: GET https://MYGITLABSERVER.MYDOMAIN.COM/api/v4/projects/MYORG/MYPROJECT/statuses/e18a4852a5fa74d2bae3cf8afa6d6e19REDACTED: 404 {error: 404 Not Found}","json":{"repo":"MYORG/MYPROJECT","pull":"270"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*DefaultPreWorkflowHooksCommandRunner).runHooks\n\t/home/runner/work/atlantis/atlantis/server/events/pre_workflow_hooks_command_runner.go:147\ngithub.com/runatlantis/atlantis/server/events.(*DefaultPreWorkflowHooksCommandRunner).RunPreHooks\n\t/home/runner/work/atlantis/atlantis/server/events/pre_workflow_hooks_command_runner.go:90\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunAutoplanCommand\n\t/home/runner/work/atlantis/atlantis/server/events/command_runner.go:193"}
Mar 05 12:48:03 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"error","ts":"2024-03-05T12:48:03.064Z","caller":"events/command_runner.go:196","msg":"Error running pre-workflow hooks GET https://MYGITLABSERVER.MYDOMAIN.COM/api/v4/projects/MYORG/MYPROJECT/statuses/e18a4852a5fa74d2bae3cf8afa6d6e19REDACTED: 404 {error: 404 Not Found}.","json":{"repo":"MYORG/MYPROJECT","pull":"270"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunAutoplanCommand\n\t/home/runner/work/atlantis/atlantis/server/events/command_runner.go:196"}
Mar 05 12:48:03 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"error","ts":"2024-03-05T12:48:03.064Z","caller":"events/command_runner.go:199","msg":"'fail-on-pre-workflow-hook-error' set, so not running plan command.","json":{"repo":"MYORG/MYPROJECT","pull":"270"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunAutoplanCommand\n\t/home/runner/work/atlantis/atlantis/server/events/command_runner.go:199"}
Mar 05 12:48:03 MYCICDSERVER.MYDOMAIN.COM atlantis[2538301]: {"level":"debug","ts":"2024-03-05T12:48:03.065Z","caller":"metrics/debug.go:52","msg":"timer","json":{"name":"atlantis.cmd.autoplan.execution_time","value":1.003306532,"tags":{},"type":"timer"}}
Environment details
Standard latest atlantis downloaded from github.
Run with: /usr/local/bin/atlantis --config /etc/atlantis-server.yaml --repo-config /etc/atlantis-repo.yaml server
Atlantis server-side config file:
Repo
atlantis.yaml
file:It's a straight up ubuntu 20.04 instance with nothing of note in the sphere of atlantis.
This current strange setup with pre-workflow hooks is necessary to cope with git submodules because Atlantis doesn't seem to do so natively. There are other horrors in there but I don't think they ever even come into play because the pre-workflow hooks fail due to the API URLs being wrong.
Additional Context
The text was updated successfully, but these errors were encountered: