From 9ba7f1a8b04a273b98f5ca13cb082a9fa045432c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Aug 2025 13:36:05 +0200 Subject: [PATCH] internal: use manifest build/payload pipelines (images#1766) With the new images library changes to move the pipeline roles out of the image types into the manifest we need to tweak osbuild-composer to use the new way of getting the payload and build pipelines. This commit implements that new method based on the manifest instead of the image type. See images pr#1766 for the rational of the change. --- internal/cloudapi/v2/server.go | 8 ++++---- internal/weldr/api.go | 4 ++-- internal/worker/json.go | 15 ++++++++++----- internal/worker/json_test.go | 16 ++++++++-------- internal/worker/server_test.go | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/internal/cloudapi/v2/server.go b/internal/cloudapi/v2/server.go index fd0fde00e..cf90cf51c 100644 --- a/internal/cloudapi/v2/server.go +++ b/internal/cloudapi/v2/server.go @@ -256,8 +256,8 @@ func (s *Server) enqueueCompose(irs []imageRequest, channel string) (uuid.UUID, id, err = s.workers.EnqueueOSBuildAsDependency(arch.Name(), &worker.OSBuildJob{ Targets: ir.targets, PipelineNames: &worker.PipelineNames{ - Build: ir.imageType.BuildPipelines(), - Payload: ir.imageType.PayloadPipelines(), + Build: manifestSource.BuildPipelines(), + Payload: manifestSource.PayloadPipelines(), }, }, []uuid.UUID{manifestJobID}, channel) if err != nil { @@ -408,8 +408,8 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas buildID, err := s.workers.EnqueueOSBuildAsDependency(arch.Name(), &worker.OSBuildJob{ PipelineNames: &worker.PipelineNames{ - Build: ir.imageType.BuildPipelines(), - Payload: ir.imageType.PayloadPipelines(), + Build: manifestSource.BuildPipelines(), + Payload: manifestSource.PayloadPipelines(), }, Targets: targets, ManifestDynArgsIdx: common.ToPtr(1), diff --git a/internal/weldr/api.go b/internal/weldr/api.go index 730d81e2a..4bb35537d 100644 --- a/internal/weldr/api.go +++ b/internal/weldr/api.go @@ -2655,8 +2655,8 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request Manifest: mf, Targets: targets, PipelineNames: &worker.PipelineNames{ - Build: imageType.BuildPipelines(), - Payload: imageType.PayloadPipelines(), + Build: manifest.BuildPipelines(), + Payload: manifest.PayloadPipelines(), }, ImageBootMode: imageType.BootMode().String(), }, "") diff --git a/internal/worker/json.go b/internal/worker/json.go index bd3e50e40..be43a2112 100644 --- a/internal/worker/json.go +++ b/internal/worker/json.go @@ -5,7 +5,6 @@ import ( "fmt" "runtime/debug" - "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/manifest" "github.com/osbuild/images/pkg/osbuild" "github.com/osbuild/images/pkg/rpmmd" @@ -368,6 +367,12 @@ type updateJobRequest struct { Result interface{} `json:"result"` } +// compat with images https://github.com/osbuild/images/pull/1766 +var ( + BuildPipelinesFallback = []string{"build"} + PayloadPipelinesFallback = []string{"os", "assembler"} +) + func (j *OSBuildJob) UnmarshalJSON(data []byte) error { // handles unmarshalling old jobs in the queue that don't contain newer fields // adds default/fallback values to missing data @@ -383,8 +388,8 @@ func (j *OSBuildJob) UnmarshalJSON(data []byte) error { } if compat.PipelineNames == nil { compat.PipelineNames = &PipelineNames{ - Build: distro.BuildPipelinesFallback(), - Payload: distro.PayloadPipelinesFallback(), + Build: BuildPipelinesFallback, + Payload: PayloadPipelinesFallback, } } @@ -439,8 +444,8 @@ func (j *OSBuildJobResult) UnmarshalJSON(data []byte) error { } if alias.PipelineNames == nil { alias.PipelineNames = &PipelineNames{ - Build: distro.BuildPipelinesFallback(), - Payload: distro.PayloadPipelinesFallback(), + Build: BuildPipelinesFallback, + Payload: PayloadPipelinesFallback, } } *j = OSBuildJobResult(alias) diff --git a/internal/worker/json_test.go b/internal/worker/json_test.go index ebe24750d..5d2f6c5aa 100644 --- a/internal/worker/json_test.go +++ b/internal/worker/json_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" - "github.com/osbuild/images/pkg/distro" + "github.com/stretchr/testify/assert" + "github.com/osbuild/osbuild-composer/internal/target" "github.com/osbuild/osbuild-composer/internal/worker/clienterrors" - "github.com/stretchr/testify/assert" ) func TestOSBuildJobResultTargetErrors(t *testing.T) { @@ -429,8 +429,8 @@ func TestOSBuildJobExportsCompatibilityUnmarshal(t *testing.T) { }, }, PipelineNames: &PipelineNames{ - Build: distro.BuildPipelinesFallback(), - Payload: distro.PayloadPipelinesFallback(), + Build: BuildPipelinesFallback, + Payload: PayloadPipelinesFallback, }, }, expectedExports: []string{"archive"}, @@ -456,8 +456,8 @@ func TestOSBuildJobExportsCompatibilityUnmarshal(t *testing.T) { }, }, PipelineNames: &PipelineNames{ - Build: distro.BuildPipelinesFallback(), - Payload: distro.PayloadPipelinesFallback(), + Build: BuildPipelinesFallback, + Payload: PayloadPipelinesFallback, }, }, expectedExports: []string{"archive"}, @@ -484,8 +484,8 @@ func TestOSBuildJobExportsCompatibilityUnmarshal(t *testing.T) { }, }, PipelineNames: &PipelineNames{ - Build: distro.BuildPipelinesFallback(), - Payload: distro.PayloadPipelinesFallback(), + Build: BuildPipelinesFallback, + Payload: PayloadPipelinesFallback, }, }, expectedExports: []string{"archive"}, diff --git a/internal/worker/server_test.go b/internal/worker/server_test.go index 5d62d38d7..bdcf41c91 100644 --- a/internal/worker/server_test.go +++ b/internal/worker/server_test.go @@ -497,7 +497,7 @@ func TestMixedOSBuildJob(t *testing.T) { BasePath: "/", } server := newTestServer(t, t.TempDir(), config, false) - fbPipelines := &worker.PipelineNames{Build: distro.BuildPipelinesFallback(), Payload: distro.PayloadPipelinesFallback()} + fbPipelines := &worker.PipelineNames{Build: worker.BuildPipelinesFallback, Payload: worker.PayloadPipelinesFallback} oldJob := worker.OSBuildJob{ Manifest: emptyManifestV2,