osbuild-worker: attach pipeline names to jobs

Pipeline names are added to each job before adding to the queue. When a
job is finished, the names are copied to the Result object as well. This
is done for both OSBuild and Koji jobs.

The pipeline names in the result are primarily used to separate package
lists into build and payload/image packages in two cases:
1. Koji builds: for reporting the build root and image package lists to
   Koji (in Koji finalize).
2. Cloud API (v1 and v2): for reporting the payload packages in the
   metadata request.

The pipeline names are also used to print the system log output in the
order in which pipelines are executed. This still isn't used when
printing the OSBuild Result (osbuild2.Result.Write()) and we still rely
on sorting by pipeline name
(see https://github.com/osbuild/osbuild-composer/pull/1330).
This commit is contained in:
Achilleas Koutsou 2021-09-10 17:13:03 +02:00 committed by Ondřej Budai
parent 143eb5cb91
commit 9aef7bfc47
7 changed files with 107 additions and 97 deletions

View file

@ -82,10 +82,11 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
}
type imageRequest struct {
manifest distro.Manifest
arch string
filename string
exports []string
manifest distro.Manifest
arch string
filename string
exports []string
pipelineNames *worker.PipelineNames
}
imageRequests := make([]imageRequest, len(request.ImageRequests))
@ -140,6 +141,10 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
imageRequests[i].arch = arch.Name()
imageRequests[i].filename = imageType.Filename()
imageRequests[i].exports = imageType.Exports()
imageRequests[i].pipelineNames = &worker.PipelineNames{
Build: imageType.BuildPipelines(),
Payload: imageType.PayloadPipelines(),
}
kojiFilenames[i] = fmt.Sprintf(
"%s-%s-%s.%s%s",
@ -168,6 +173,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
Manifest: ir.manifest,
ImageName: ir.filename,
Exports: ir.exports,
PipelineNames: ir.pipelineNames,
KojiServer: request.Koji.Server,
KojiDirectory: kojiDirectory,
KojiFilename: kojiFilenames[i],
@ -432,8 +438,8 @@ func (h *apiHandlers) getFinalizeJob(id uuid.UUID) (*worker.KojiFinalizeJob, []u
}
// getInitJob retrieves a KojiInitJob from the job queue given its ID.
// It returns an error if the ID matches a job of a different type.
func (h *apiHandlers) getInitJob(id uuid.UUID) (*worker.KojiInitJob, error) {
// It returns an error if the ID matches a job of a different type.
job := new(worker.KojiInitJob)
jobType, _, _, err := h.server.workers.Job(id, job)
if err != nil {