diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index a8041030c..52ab08113 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -281,7 +281,17 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { if len(args.Manifest) == 0 { if job.NDynamicArgs() > 0 { var manifestJR worker.ManifestJobByIDResult - err = job.DynamicArgs(0, &manifestJR) + if job.NDynamicArgs() == 1 { + // Classic case of a compose request with the ManifestJobByID job as the single dependency + err = job.DynamicArgs(0, &manifestJR) + } else if job.NDynamicArgs() > 1 && args.ManifestDynArgsIdx != nil { + // Case when the job has multiple dependencies, but the manifest is not part of the static job arguments, + // but rather in the dynamic arguments (e.g. from ManifestJobByID job). + if *args.ManifestDynArgsIdx > job.NDynamicArgs()-1 { + panic("ManifestDynArgsIdx is out of range of the number of dynamic job arguments") + } + err = job.DynamicArgs(*args.ManifestDynArgsIdx, &manifestJR) + } if err != nil { osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args") return err @@ -293,11 +303,9 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { return nil } args.Manifest = manifestJR.Manifest - if len(args.Manifest) == 0 { - osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, "Received empty manifest") - return nil - } - } else { + } + + if len(args.Manifest) == 0 { osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, "Job has no manifest") return nil } diff --git a/internal/worker/json.go b/internal/worker/json.go index dc75f965d..83e32636d 100644 --- a/internal/worker/json.go +++ b/internal/worker/json.go @@ -16,9 +16,11 @@ import ( // type OSBuildJob struct { - Manifest distro.Manifest `json:"manifest,omitempty"` - Targets []*target.Target `json:"targets,omitempty"` - ImageName string `json:"image_name,omitempty"` + Manifest distro.Manifest `json:"manifest,omitempty"` + // Index of the ManifestJobByIDResult instance in the job's dynamic arguments slice + ManifestDynArgsIdx *int `json:"manifest_dyn_args_idx,omitempty"` + Targets []*target.Target `json:"targets,omitempty"` + ImageName string `json:"image_name,omitempty"` // TODO: Delete this after "some" time (kept for backward compatibility) StreamOptimized bool `json:"stream_optimized,omitempty"`