From b88645ea6d32d9016ad3b8b54e1ed9481402f8c0 Mon Sep 17 00:00:00 2001 From: grokspawn Date: Fri, 30 May 2025 11:30:13 -0500 Subject: [PATCH] only create cachedir if requested, since otherwise opm will error out serving it Signed-off-by: grokspawn --- pkg/controller/registry/reconciler/reconciler.go | 8 +++++--- pkg/controller/registry/reconciler/reconciler_test.go | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/controller/registry/reconciler/reconciler.go b/pkg/controller/registry/reconciler/reconciler.go index ba3df3222b..3455bcb2c3 100644 --- a/pkg/controller/registry/reconciler/reconciler.go +++ b/pkg/controller/registry/reconciler/reconciler.go @@ -305,12 +305,14 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s pod.Spec.Containers[0].Image = opmImg pod.Spec.Containers[0].Command = []string{"/bin/opm"} - // set service cache dir unconditionally, since it should always have compatible permissions for generation, if not provided by grpcPodConfig - pod.Spec.Containers[0].Args = []string{ + var containerArgs = []string{ "serve", filepath.Join(catalogPath, "catalog"), - "--cache-dir=" + filepath.Join(catalogPath, "cache"), } + if grpcPodConfig.ExtractContent.CacheDir != "" { + containerArgs = append(containerArgs, "--cache-dir="+filepath.Join(catalogPath, "cache")) + } + pod.Spec.Containers[0].Args = containerArgs pod.Spec.Containers[0].VolumeMounts = append(pod.Spec.Containers[0].VolumeMounts, contentVolumeMount) } } diff --git a/pkg/controller/registry/reconciler/reconciler_test.go b/pkg/controller/registry/reconciler/reconciler_test.go index 959d1aeaa2..783801cf93 100644 --- a/pkg/controller/registry/reconciler/reconciler_test.go +++ b/pkg/controller/registry/reconciler/reconciler_test.go @@ -400,7 +400,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "b0yrMl85J8bFjFWNl1O2XxsX698iPAjbpNhRIT", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "b4ns9MTvaRBYOarmuFe6PLYK0r2kxj5Vo06WTU", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -444,7 +444,7 @@ func TestPodExtractContent(t *testing.T) { Name: "name", Image: "opmImage", Command: []string{"/bin/opm"}, - Args: []string{"serve", "/extracted-catalog/catalog", "--cache-dir=/extracted-catalog/cache"}, + Args: []string{"serve", "/extracted-catalog/catalog"}, Ports: []corev1.ContainerPort{{Name: "grpc", ContainerPort: 50051}}, ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ @@ -719,7 +719,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "3qxzUcTKDfq8QwZPoXteAv35FSwRho7vyYkv4d", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "cO4moUo3vz6jZlcoBcxY4BB8o8a4E7m5GXCzI", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -771,7 +771,7 @@ func TestPodExtractContent(t *testing.T) { Name: "name", Image: "opmImage", Command: []string{"/bin/opm"}, - Args: []string{"serve", "/extracted-catalog/catalog", "--cache-dir=/extracted-catalog/cache"}, + Args: []string{"serve", "/extracted-catalog/catalog"}, Ports: []corev1.ContainerPort{{Name: "grpc", ContainerPort: 50051}}, ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{