Worker: report stages status after RunOSBuild

To help along with debugging, this commit makes the worker able to print
the status of the different stages with a oneliner for each successfull
stages and a detailed message for failed ones.

Sample output:
Jul 23[..]: Build stages results:
Jul 23[..]: org.osbuild.rpm  success
Jul 23[..]: org.osbuild.selinux  success
Jul 23[..]: Stages results:
Jul 23[..]: org.osbuild.rpm  success
Jul 23[..]: org.osbuild.fix-bls  success
Jul 23[..]: org.osbuild.fstab  success
Jul 23[..]: org.osbuild.grub2  success
Jul 23[..]: org.osbuild.locale  success
Jul 23[..]: org.osbuild.timezone  success
Jul 23[..]: org.osbuild.users failure:
Jul 23[..]:  [/usr/lib/tmpfiles.d/journal-nocow.conf:26] Failed to resolve specifier: uninitialized /etc detected, skipping
Jul 23[..]: All rules containing unresolvable specifiers will be skipped.
Jul 23[..]: Failed to create file /sys/fs/selinux/checkreqprot: Read-only file system
Jul 23[..]: useradd: group 'toto' does not exist

Fixes #1584
This commit is contained in:
Thomas Lavocat 2021-07-23 15:50:07 +02:00 committed by Ondřej Budai
parent df1eddbf07
commit 5e127de303

View file

@ -96,6 +96,37 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
if err != nil {
return err
}
log.Println("Build stages results:")
// Include the build stages output inside the worker's logs.
for _, stage := range osbuildJobResult.OSBuildOutput.Build.Stages {
if stage.Success {
log.Println(stage.Name, " success")
} else {
log.Printf("%s failure:\n", stage.Name)
stageOutput := strings.Split(stage.Output, "\n")
for _, line := range stageOutput {
log.Printf(" %s", line)
}
}
}
log.Println("Stages results:")
// Include the stages output inside the worker's logs.
for _, stage := range osbuildJobResult.OSBuildOutput.Stages {
if stage.Success {
log.Println(stage.Name, " success")
} else {
log.Printf("%s failure:\n", stage.Name)
stageOutput := strings.Split(stage.Output, "\n")
for _, line := range stageOutput {
log.Printf(" %s", line)
}
}
}
// Second handle the case when the build failed, but osbuild finished successfully
if !osbuildJobResult.OSBuildOutput.Success {
return nil