From 6756e1d001a87d8b0a23c3a5b6dfa918e0a14152 Mon Sep 17 00:00:00 2001 From: Paul Bastide Date: Fri, 5 Dec 2025 20:21:09 -0500 Subject: [PATCH 1/3] fix: multi-arch Signed-off-by: Paul Bastide --- Makefile | 4 ++-- .../e2e/templates/isc_templates/release_isc.yaml | 4 ++++ internal/testutils/testutils.go | 13 +++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index df0aa387e..be9695eed 100644 --- a/Makefile +++ b/Makefile @@ -52,8 +52,8 @@ test-unit: test-integration: mkdir -p tests/results-integration - $(GO) test $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) -coverprofile=tests/results-integration/cover-additional.out -race -count=1 ./internal/pkg/... -run TestIntegrationAdditional - $(GO) test $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) -coverprofile=tests/results-integration/cover-release.out -race -count=1 ./internal/pkg/... -run TestIntegrationRelease + $(GO) test $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) -coverprofile=tests/results-integration/cover-additional.out -race -count=1 ./internal/pkg/... -run 'TestIntegrationAdditional$' + $(GO) test $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) -coverprofile=tests/results-integration/cover-release.out -race -count=1 ./internal/pkg/... -run 'TestIntegrationRelease$' $(GO) test $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) -coverprofile=tests/results-integration/cover-additional.out -race -count=1 ./internal/pkg/... -run TestIntegrationAdditionalM2M $(GO) test $(GO_MOD_FLAGS) $(GO_BUILD_FLAGS) -coverprofile=tests/results-integration/cover-release.out -race -count=1 ./internal/pkg/... -run TestIntegrationReleaseM2M make -C v1 test-integration diff --git a/internal/e2e/templates/isc_templates/release_isc.yaml b/internal/e2e/templates/isc_templates/release_isc.yaml index fa91e5aac..bcb1e738c 100644 --- a/internal/e2e/templates/isc_templates/release_isc.yaml +++ b/internal/e2e/templates/isc_templates/release_isc.yaml @@ -3,6 +3,10 @@ kind: ImageSetConfiguration apiVersion: mirror.openshift.io/v2alpha1 mirror: platform: + architectures: + - "multi" + - "ppc64le" + - "amd64" channels: - name: {{.}} graph: true diff --git a/internal/testutils/testutils.go b/internal/testutils/testutils.go index 83a8d14d6..c6b3c2411 100644 --- a/internal/testutils/testutils.go +++ b/internal/testutils/testutils.go @@ -13,6 +13,7 @@ import ( "os" "path" "path/filepath" + "runtime" "strings" "text/template" @@ -23,6 +24,7 @@ import ( v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/empty" "github.com/google/go-containerregistry/pkg/v1/layout" + "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/openshift/oc-mirror/v2/internal/pkg/image" ) @@ -127,6 +129,17 @@ func buildAndPushFakeImage(content map[string][]byte, imgRef string, dir string) return "", err } i, _ := crane.Image(content) + // Set the platform to match the local GOARCH + cfg, err := i.ConfigFile() + if err != nil { + return "", err + } + cfg.OS = runtime.GOOS + cfg.Architecture = runtime.GOARCH + i, err = mutate.ConfigFile(i, cfg) + if err != nil { + return "", err + } if err := crane.Push(i, tag.String()); err != nil { return "", err } From 4b14bd58059eae6042013ce3d01a771096faa0e0 Mon Sep 17 00:00:00 2001 From: Paul Bastide Date: Fri, 5 Dec 2025 20:29:56 -0500 Subject: [PATCH 2/3] fix: release_isc reset, archive refactored Signed-off-by: Paul Bastide --- internal/e2e/templates/isc_templates/release_isc.yaml | 4 ---- internal/pkg/archive/archive.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/e2e/templates/isc_templates/release_isc.yaml b/internal/e2e/templates/isc_templates/release_isc.yaml index bcb1e738c..fa91e5aac 100644 --- a/internal/e2e/templates/isc_templates/release_isc.yaml +++ b/internal/e2e/templates/isc_templates/release_isc.yaml @@ -3,10 +3,6 @@ kind: ImageSetConfiguration apiVersion: mirror.openshift.io/v2alpha1 mirror: platform: - architectures: - - "multi" - - "ppc64le" - - "amd64" channels: - name: {{.}} graph: true diff --git a/internal/pkg/archive/archive.go b/internal/pkg/archive/archive.go index 174ccd971..b0f6d736d 100644 --- a/internal/pkg/archive/archive.go +++ b/internal/pkg/archive/archive.go @@ -144,9 +144,15 @@ func (o *MirrorArchive) addImagesDiff(ctx context.Context, collectedImages []v2a return nil, fmt.Errorf("unable to find blobs corresponding to %s: %w", img.Destination, err) } - if err := handleSignatureErrors(img, err); err != nil { + // Handle signature errors - only return error if it's a fatal signature error + if sigHandleErr := handleSignatureErrors(img, err); sigHandleErr != nil { var archiveErr *ArchiveError - if errors.As(err, &archiveErr) && archiveErr.ReleaseErr != nil { + if errors.As(sigHandleErr, &archiveErr) && archiveErr.ReleaseErr != nil { + // For release images, signature errors should not be fatal + // Log the error but continue processing + o.logger.Warn("signature error for release image %s: %v", img.Destination, archiveErr.ReleaseErr) + } else if errors.As(sigHandleErr, &archiveErr) { + // For other image types, return the error return nil, archiveErr } } From b725b96b18a210970d7a2f39f4af372b2fe2d7a9 Mon Sep 17 00:00:00 2001 From: Paul Bastide Date: Fri, 5 Dec 2025 20:41:11 -0500 Subject: [PATCH 3/3] fix: remove signatures as they aren't generated in the code Signed-off-by: Paul Bastide --- internal/pkg/archive/archive.go | 10 ++-------- internal/pkg/cli/release_integration_test.go | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/internal/pkg/archive/archive.go b/internal/pkg/archive/archive.go index b0f6d736d..174ccd971 100644 --- a/internal/pkg/archive/archive.go +++ b/internal/pkg/archive/archive.go @@ -144,15 +144,9 @@ func (o *MirrorArchive) addImagesDiff(ctx context.Context, collectedImages []v2a return nil, fmt.Errorf("unable to find blobs corresponding to %s: %w", img.Destination, err) } - // Handle signature errors - only return error if it's a fatal signature error - if sigHandleErr := handleSignatureErrors(img, err); sigHandleErr != nil { + if err := handleSignatureErrors(img, err); err != nil { var archiveErr *ArchiveError - if errors.As(sigHandleErr, &archiveErr) && archiveErr.ReleaseErr != nil { - // For release images, signature errors should not be fatal - // Log the error but continue processing - o.logger.Warn("signature error for release image %s: %v", img.Destination, archiveErr.ReleaseErr) - } else if errors.As(sigHandleErr, &archiveErr) { - // For other image types, return the error + if errors.As(err, &archiveErr) && archiveErr.ReleaseErr != nil { return nil, archiveErr } } diff --git a/internal/pkg/cli/release_integration_test.go b/internal/pkg/cli/release_integration_test.go index 3cab88548..36a5e0d22 100644 --- a/internal/pkg/cli/release_integration_test.go +++ b/internal/pkg/cli/release_integration_test.go @@ -169,7 +169,7 @@ func (suite *TestEnvironmentRelease) runMirror2Disk(t *testing.T) { err := os.MkdirAll(resultFolder, 0755) assert.NoError(t, err, "should not fail creating a temp folder for results") - ocmirror.SetArgs([]string{"-c", suite.tempFolder + "/isc.yaml", "--v2", "-p", "56001", "--src-tls-verify=false", "--dest-tls-verify=false", "file://" + resultFolder}) + ocmirror.SetArgs([]string{"-c", suite.tempFolder + "/isc.yaml", "--v2", "-p", "56001", "--src-tls-verify=false", "--dest-tls-verify=false", "--remove-signatures", "file://" + resultFolder}) err = ocmirror.Execute() assert.NoError(t, err, "should not fail executing oc-mirror")