Skip to content

Commit

Permalink
osbuild-worker: improve error "reason" in case of stage failures
Browse files Browse the repository at this point in the history
  • Loading branch information
schuellerf committed Jun 17, 2024
1 parent b8a2592 commit 5b2a520
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/osbuild-worker/jobimpl-osbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,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() {
Expand All @@ -556,6 +557,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)
Expand All @@ -575,7 +577,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
}

Expand Down

0 comments on commit 5b2a520

Please sign in to comment.