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 Apr 29, 2024
1 parent 5a776c5 commit d846b4d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/osbuild-worker/jobimpl-osbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand 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)
Expand All @@ -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
}

Expand Down

0 comments on commit d846b4d

Please sign in to comment.