osbuild-worker: use v2 Result struct
- koji-finalize: Use v2 result type to collect RPM metadata. The separation between the "build" pipeline and the rest is based on the pipeline name, which isn't completely reliable since pipeline names can be arbitrary. Koji will fail a build if it specifies duplicate packages, so the RPM lists are deduplicated. The "build" pipeline package list is also deduplicated in case there are multiple build stages in the same pipeline. - osbuild: Use v2 result type for printing build result to log. Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
fbdc19f6d8
commit
8dce5aa688
3 changed files with 42 additions and 30 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/url"
|
||||
"time"
|
||||
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/koji"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
|
|
@ -132,6 +133,12 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
var buildRoots []koji.BuildRoot
|
||||
var images []koji.Image
|
||||
for i, buildArgs := range osbuildKojiResults {
|
||||
buildPipelineMd := buildArgs.OSBuildOutput.Metadata["build"]
|
||||
buildRPMs := rpmmd.OSBuildMetadataToRPMs(buildPipelineMd)
|
||||
// this dedupe is usually not necessary since we generally only have
|
||||
// one rpm stage in the build pipeline, but it's not invalid to have
|
||||
// multiple
|
||||
buildRPMs = rpmmd.DeduplicateRPMs(buildRPMs)
|
||||
buildRoots = append(buildRoots, koji.BuildRoot{
|
||||
ID: uint64(i),
|
||||
Host: koji.Host{
|
||||
|
|
@ -147,8 +154,27 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
Arch: buildArgs.Arch,
|
||||
},
|
||||
Tools: []koji.Tool{},
|
||||
RPMs: rpmmd.OSBuildStagesToRPMs(buildArgs.OSBuildOutput.Build.Stages),
|
||||
RPMs: buildRPMs,
|
||||
})
|
||||
|
||||
// collect metadata from all other pipelines
|
||||
// use pipeline name + stage name as key while collecting since all RPM
|
||||
// stage metadata will have the same key within a single pipeline
|
||||
imagePipelinesMd := make(map[string]osbuild.StageMetadata)
|
||||
for pipelineName, pipelineMetadata := range buildArgs.OSBuildOutput.Metadata {
|
||||
if pipelineName == "build" {
|
||||
continue
|
||||
}
|
||||
for stageName, stageMetadata := range pipelineMetadata {
|
||||
imagePipelinesMd[pipelineName+":"+stageName] = stageMetadata
|
||||
}
|
||||
}
|
||||
|
||||
// collect packages from all stages
|
||||
imageRPMs := rpmmd.OSBuildMetadataToRPMs(imagePipelinesMd)
|
||||
// deduplicate
|
||||
imageRPMs = rpmmd.DeduplicateRPMs(imageRPMs)
|
||||
|
||||
images = append(images, koji.Image{
|
||||
BuildRootID: uint64(i),
|
||||
Filename: args.KojiFilenames[i],
|
||||
|
|
@ -157,7 +183,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
ChecksumType: "md5",
|
||||
MD5: buildArgs.ImageHash,
|
||||
Type: "image",
|
||||
RPMs: rpmmd.OSBuildStagesToRPMs(buildArgs.OSBuildOutput.Stages),
|
||||
RPMs: imageRPMs,
|
||||
Extra: koji.ImageExtra{
|
||||
Info: koji.ImageExtraInfo{
|
||||
Arch: buildArgs.Arch,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
"github.com/osbuild/osbuild-composer/internal/cloud/gcp"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild1"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/awsupload"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/azure"
|
||||
|
|
@ -120,32 +120,18 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
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)
|
||||
// Include pipeline stages output inside the worker's logs.
|
||||
for pipelineName, pipelineLog := range osbuildJobResult.OSBuildOutput.Log {
|
||||
log.Printf("%s pipeline results:\n", pipelineName)
|
||||
for _, stageResult := range pipelineLog {
|
||||
if stageResult.Success {
|
||||
log.Printf(" %s success", stageResult.Type)
|
||||
} else {
|
||||
log.Printf(" %s failure:", stageResult.Type)
|
||||
stageOutput := strings.Split(stageResult.Output, "\n")
|
||||
for _, line := range stageOutput {
|
||||
log.Printf(" %s", line)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"os/exec"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild1"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
)
|
||||
|
||||
// Run an instance of osbuild, returning a parsed osbuild.Result.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue