From 6fa8f68232601580c8316165004a9f913fb40dcb Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Thu, 12 Nov 2026 17:51:04 +0100 Subject: [PATCH 1/5] No need to transfer the bundle image to the local cluster --- internal/deployer/acs_images.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/deployer/acs_images.go b/internal/deployer/acs_images.go index 48043b0e..b8782c71 100644 --- a/internal/deployer/acs_images.go +++ b/internal/deployer/acs_images.go @@ -9,10 +9,7 @@ func imagesForConfig(config Config) []string { for _, imageName := range relatedImages { images = append(images, constructOperandImageFromInstance(instance, imageName)) } - images = append(images, - instance.OperatorImage(), - instance.BundleImage(), - ) + images = append(images, instance.OperatorImage()) } return images From 6e16049c2d0b60c71cd43b2512f8179783c5927c Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Thu, 12 Nov 2026 19:35:34 +0100 Subject: [PATCH 2/5] Check if operator-bundle exists in local registry. --- go.mod | 2 +- internal/deployer/operator.go | 9 +++++++++ internal/ocihelper/ocihelper.go | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 86aad35a..0909ae42 100644 --- a/go.mod +++ b/go.mod @@ -98,7 +98,7 @@ require ( require ( github.com/Microsoft/go-winio v0.6.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs v1.0.0 github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/distribution/reference v0.6.0 // indirect diff --git a/internal/deployer/operator.go b/internal/deployer/operator.go index f759f977..577d2b56 100644 --- a/internal/deployer/operator.go +++ b/internal/deployer/operator.go @@ -211,6 +211,15 @@ func (d *Deployer) resolveBundleImage(ctx context.Context, instance OperatorInst return bundleImage, nil } + exists, err := ocihelper.ImageExistsInDaemon(ctx, bundleImage, d.containerRuntimeSocket) + if err != nil { + log.Dimf("Could not check local daemon for bundle image %s: %v", bundleImage, err) + } + if exists { + log.Dimf("✓ Bundle image %s found in local daemon, skipping remote registry check", bundleImage) + return bundleImage, nil + } + if err := ocihelper.VerifyImageExistence(ctx, bundleImage); err != nil { var te *transport.Error if errors.As(err, &te) && te.StatusCode == http.StatusNotFound { diff --git a/internal/ocihelper/ocihelper.go b/internal/ocihelper/ocihelper.go index 2cc2e02a..465f718d 100644 --- a/internal/ocihelper/ocihelper.go +++ b/internal/ocihelper/ocihelper.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" + cerrdefs "github.com/containerd/errdefs" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/daemon" @@ -18,6 +19,34 @@ import ( log "github.com/stackrox/roxie/internal/logger" ) +// ImageExistsInDaemon reports whether the image is available in the local +// container runtime (Docker/Podman) reachable via containerRuntimeSocket. +func ImageExistsInDaemon(ctx context.Context, imageRef, containerRuntimeSocket string) (bool, error) { + ref, err := name.ParseReference(imageRef) + if err != nil { + return false, fmt.Errorf("parsing image reference %q: %w", imageRef, err) + } + + daemonOpts := []daemon.Option{daemon.WithContext(ctx)} + if containerRuntimeSocket != "" { + client, err := mobyclient.New(mobyclient.WithHost(containerRuntimeSocket)) + if err != nil { + return false, fmt.Errorf("connecting to local daemon: %w", err) + } + defer client.Close() + daemonOpts = append(daemonOpts, daemon.WithClient(client)) + } + + _, err = daemon.Image(ref, daemonOpts...) + if cerrdefs.IsNotFound(err) { + return false, nil + } + if err != nil { + return false, fmt.Errorf("inspecting image %s: %w", ref, err) + } + return true, nil +} + // VerifyImageExistence verifies that an OCI image is accessible. // Authentication is handled automatically from ~/.docker/config.json or $REGISTRY_AUTH_FILE. func VerifyImageExistence(ctx context.Context, imageRef string) error { From e5076f62cc79363ac0e1690a9b20248e70dd8918 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Wed, 18 Nov 2026 10:26:49 +0100 Subject: [PATCH 3/5] Update imagesForConfig tests: bundle image is no longer preloaded Co-Authored-By: Claude Opus 5.5 --- internal/deployer/operator_instances_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/deployer/operator_instances_test.go b/internal/deployer/operator_instances_test.go index edf4f3cc..600bfde6 100644 --- a/internal/deployer/operator_instances_test.go +++ b/internal/deployer/operator_instances_test.go @@ -267,8 +267,8 @@ func TestImagesForConfig_MixedVersions(t *testing.T) { assert.Contains(t, images, "quay.io/rhacs-eng/main:4.9.0") assert.Contains(t, images, "quay.io/rhacs-eng/stackrox-operator:4.8.0") assert.Contains(t, images, "quay.io/rhacs-eng/stackrox-operator:4.9.0") - assert.Contains(t, images, "quay.io/rhacs-eng/stackrox-operator-bundle:v4.8.0") - assert.Contains(t, images, "quay.io/rhacs-eng/stackrox-operator-bundle:v4.9.0") + assert.NotContains(t, images, "quay.io/rhacs-eng/stackrox-operator-bundle:v4.8.0") + assert.NotContains(t, images, "quay.io/rhacs-eng/stackrox-operator-bundle:v4.9.0") } func TestImagesForConfig_SingleVersionUnchanged(t *testing.T) { @@ -282,7 +282,7 @@ func TestImagesForConfig_SingleVersionUnchanged(t *testing.T) { images := imagesForConfig(cfg) assert.Contains(t, images, "quay.io/rhacs-eng/main:4.9.0") assert.Contains(t, images, "quay.io/rhacs-eng/stackrox-operator:4.9.0") - assert.Contains(t, images, "quay.io/rhacs-eng/stackrox-operator-bundle:v4.9.0") + assert.NotContains(t, images, "quay.io/rhacs-eng/stackrox-operator-bundle:v4.9.0") mainCount := 0 for _, img := range images { From a18dbe74ebf35255493a3c2593b4327f1c493ca3 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Wed, 18 Nov 2026 10:30:09 +0100 Subject: [PATCH 4/5] Bound local daemon image probe with a 5s timeout An unresponsive Docker/Podman socket would otherwise block bundle image resolution until the deploy deadline, preventing the registry fallback. Co-Authored-By: Claude Opus 5.5 --- internal/ocihelper/ocihelper.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/ocihelper/ocihelper.go b/internal/ocihelper/ocihelper.go index 465f718d..2fcffd3d 100644 --- a/internal/ocihelper/ocihelper.go +++ b/internal/ocihelper/ocihelper.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "path/filepath" + "time" cerrdefs "github.com/containerd/errdefs" "github.com/google/go-containerregistry/pkg/name" @@ -19,6 +20,10 @@ import ( log "github.com/stackrox/roxie/internal/logger" ) +// daemonProbeTimeout bounds the local daemon lookup so an unresponsive +// Docker/Podman socket doesn't block callers that have other fallbacks. +const daemonProbeTimeout = 5 * time.Second + // ImageExistsInDaemon reports whether the image is available in the local // container runtime (Docker/Podman) reachable via containerRuntimeSocket. func ImageExistsInDaemon(ctx context.Context, imageRef, containerRuntimeSocket string) (bool, error) { @@ -27,6 +32,9 @@ func ImageExistsInDaemon(ctx context.Context, imageRef, containerRuntimeSocket s return false, fmt.Errorf("parsing image reference %q: %w", imageRef, err) } + ctx, cancel := context.WithTimeout(ctx, daemonProbeTimeout) + defer cancel() + daemonOpts := []daemon.Option{daemon.WithContext(ctx)} if containerRuntimeSocket != "" { client, err := mobyclient.New(mobyclient.WithHost(containerRuntimeSocket)) From bd689368261764dd782b8f806a7b5341ffc2b724 Mon Sep 17 00:00:00 2001 From: Moritz Clasmeier Date: Wed, 18 Nov 2026 12:22:49 +0100 Subject: [PATCH 5/5] Share daemon image lookup and close moby client Co-Authored-By: Claude Opus 5.5 --- internal/ocihelper/ocihelper.go | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/internal/ocihelper/ocihelper.go b/internal/ocihelper/ocihelper.go index 2fcffd3d..f46b78b9 100644 --- a/internal/ocihelper/ocihelper.go +++ b/internal/ocihelper/ocihelper.go @@ -35,24 +35,32 @@ func ImageExistsInDaemon(ctx context.Context, imageRef, containerRuntimeSocket s ctx, cancel := context.WithTimeout(ctx, daemonProbeTimeout) defer cancel() + img, err := lookupImageFromDaemon(ctx, ref, containerRuntimeSocket) + if err != nil { + return false, err + } + return img != nil, nil +} + +func lookupImageFromDaemon(ctx context.Context, ref name.Reference, containerRuntimeSocket string) (v1.Image, error) { daemonOpts := []daemon.Option{daemon.WithContext(ctx)} if containerRuntimeSocket != "" { client, err := mobyclient.New(mobyclient.WithHost(containerRuntimeSocket)) if err != nil { - return false, fmt.Errorf("connecting to local daemon: %w", err) + return nil, fmt.Errorf("connecting to local daemon: %w", err) } defer client.Close() daemonOpts = append(daemonOpts, daemon.WithClient(client)) } - _, err = daemon.Image(ref, daemonOpts...) + img, err := daemon.Image(ref, daemonOpts...) if cerrdefs.IsNotFound(err) { - return false, nil + return nil, nil } if err != nil { - return false, fmt.Errorf("inspecting image %s: %w", ref, err) + return nil, fmt.Errorf("inspecting image %s: %w", ref, err) } - return true, nil + return img, nil } // VerifyImageExistence verifies that an OCI image is accessible. @@ -110,23 +118,17 @@ func assureImageExistsLocally(ctx context.Context, imageRef, containerRuntimeSoc return nil, fmt.Errorf("invalid image reference: %w", err) } - daemonOpts := []daemon.Option{daemon.WithContext(ctx)} - if containerRuntimeSocket != "" { - client, err := mobyclient.New(mobyclient.WithHost(containerRuntimeSocket)) - if err == nil { - daemonOpts = append(daemonOpts, daemon.WithClient(client)) - } else { - log.Dimf("Failed to create moby client for %s: %v", containerRuntimeSocket, err) - } - } - - img, err := daemon.Image(ref, daemonOpts...) - if err == nil { + img, err := lookupImageFromDaemon(ctx, ref, containerRuntimeSocket) + if img != nil { log.Dimf("✓ Image %s found in local daemon", imageRef) return img, nil } - log.Dimf("Image not found in local daemon, pulling from registry: %v", err) + if err != nil { + log.Dimf("Could not check local daemon, pulling from registry: %v", err) + } else { + log.Dim("Image not found in local daemon, pulling from registry") + } // For operator bundles, we fetch linux/amd64 by default as they contain // platform-agnostic YAML files.