From d846b4d765926446b60d97ae22ea351489af5bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Mon, 29 Apr 2024 13:43:16 +0200 Subject: [PATCH] osbuild-worker: improve error "reason" in case of stage failures --- cmd/osbuild-worker/jobimpl-osbuild.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index 4dde72ce0bb..68162e5d1b1 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -520,6 +520,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { return err } + var failedStages []string // Include pipeline stages output inside the worker's logs. // Order pipelines based on PipelineNames from job for _, pipelineName := range osbuildJobResult.PipelineNames.All() { @@ -534,6 +535,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { logWithId.Infof(" %s success", stageResult.Type) } else { logWithId.Infof(" %s failure:", stageResult.Type) + failedStages = append(failedStages, stageResult.Type) stageOutput := strings.Split(stageResult.Output, "\n") for _, line := range stageOutput { logWithId.Infof(" %s", line) @@ -553,7 +555,16 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { osbErrors = append(osbErrors, fmt.Errorf("manifest validation error: %v", err)) } } - osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", osbErrors) + + reason := "osbuild build failed" + if len(failedStages) > 0 { + reason += " in stage" + if len(failedStages) > 1 { + reason += "s" + } + reason += ":\n" + strings.Join(failedStages, "\n") + } + osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, osbErrors) return nil }