Closed joaoluchetti closed 1 week ago
@joaoluchetti Hello there! I'm here to assist you with any bugs, questions, or contributions while we wait for a human maintainer.
The issue you're encountering with the Atlantis Gitlab integration on version v0.29.0, where the pipeline status is stuck on "Checking pipeline status" after adding new commits to a Merge Request, is likely due to the GetAtlantisStatus
function expecting exactly one pipeline to be associated with a Merge Request. If there are multiple pipelines, it returns an error, causing the status to remain in a checking state.
Here's the relevant part of the code:
func (g GitlabClient) GetAtlantisStatus(ctx context.Context, branchName string) (string, error) {
pipelineInfos, _, err := g.client.MergeRequests.ListMergeRequestPipelines(g.projectId, g.branchToMR[branchName])
if (err != nil) {
return "", err
}
if len(pipelineInfos) != 1 {
return "", fmt.Errorf("unexpected pipelines: %d", len(pipelineInfos))
}
pipelineInfo := pipelineInfos[0]
pipeline, _, err := g.client.Pipelines.GetPipeline(g.projectId, pipelineInfo.ID)
if err != nil) {
return "", err
}
return pipeline.Status, nil
}
Additionally, the updateProjectPRStatus
function in project_command_runner.go
handles errors by setting the commit status to FailedCommitStatus
if there is an error or failure in the result of the executed command. A 404 Not Found error specifically occurs when the directory does not exist, indicated by the DirNotExistErr
error type.
Here is the relevant code:
func (p *ProjectOutputWrapper) updateProjectPRStatus(commandName command.Name, ctx command.ProjectContext, execute func(ctx command.ProjectContext) command.ProjectResult) command.ProjectResult {
if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.PendingCommitStatus, nil); err != nil {
ctx.Log.Err("updating project PR status", err)
}
result := execute(ctx)
if result.Error != nil || result.Failure != "" {
if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.FailedCommitStatus, &result); err != nil {
ctx.Log.Err("updating project PR status", err)
}
return result
}
if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.SuccessCommitStatus, &result); err != nil {
ctx.Log.Err("updating project PR status", err)
}
return result
}
The DirNotExistErr
error type:
type DirNotExistErr struct {
RepoRelDir string
}
func (d DirNotExistErr) Error() string {
return fmt.Sprintf("dir %q does not exist", d.RepoRelDir)
}
For more details, you can refer to the related issue here [1][2][3].
To continue talking to Dosu, mention @dosu.
+1
same here with the v0.29.0 version!
I just wanted to chime in and say that the problem is still present in v0.30.0. The error I had was
{"level":"warn","ts":"2024-10-03T12:44:17.887Z","caller":"events/pre_workflow_hooks_command_runner.go:144","msg":"unable to update pre workflow hook status: 404 Not Found","json":{"repo":"myorg/myrepo","pull":"519"},"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:361"}
...and then of course several others while also trying to make the thing work again. 0.28.5 works fine.
can reproduce
Hi All,
After updating to atlantis v0.29.0 we are having issues when updating Gitlab Merge Requests with new commits.
When the MR is opened the atlantis pipeline runs without any issue, although when we add another commit to the MR the status of pipeline is stuck on "Checking pipeline status", the atlantis plan and apply run without any issues but we can't merge the MR as the pipeline is not identified as succeded.
Looking at the logs we found the following exception:
2024-09-25 14:17:19.087 {"level":"error","ts":"2024-09-25T17:17:19.087Z","caller":"events/project_command_runner.go:195","msg":"updating project PR status%!(EXTRA *errors.errorString=404 Not Found)","json":{"repo":"myorg/myrepo","pull":"133"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).updateProjectPRStatus\n\tgithub.com/runatlantis/atlantis/server/events/project_command_runner.go:195\ngithub.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).Plan\n\tgithub.com/runatlantis/atlantis/server/events/project_command_runner.go:164\ngithub.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:74\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Plan\n\tgithub.com/runatlantis/atlantis/server/events/instrumented_project_command_runner.go:38\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:48\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).runAutoplan\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:136\ngithub.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/plan_command_runner.go:305\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunAutoplanCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:223"}
We can confirm that this behavior does not happen on version v0.28.x.