From ed430264525873d19e80ef9aa33bb629f8fecd8d 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index 6f3930cbb32..76c1700ad93 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 failedStage 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) + failedStage = stageResult.Type stageOutput := strings.Split(stageResult.Output, "\n") for _, line := range stageOutput { logWithId.Infof(" %s", line) @@ -553,7 +555,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { osbErrors = append(osbErrors, fmt.Sprintf("manifest validation error: %v", err)) } } - osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", osbErrors) + + reason := "osbuild build failed" + if len(failedStage) > 0 { + reason += " in stage:\n" + failedStage + } + osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, osbErrors) return nil }