From 8b77b3672b2e6979d70000605c46075ed349db94 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Fri, 12 Apr 2024 17:39:12 -0400 Subject: [PATCH] OCPBUGS-28230: fallback to logs for termination message (#3203) Signed-off-by: Joe Lanford Upstream-repository: operator-lifecycle-manager Upstream-commit: 8434d3c13431dd1985e01d1b8b3d7cb07033180f --- .../pkg/controller/bundle/bundle_unpacker.go | 3 +++ .../controller/bundle/bundle_unpacker_test.go | 18 ++++++++++++++++++ .../registry/reconciler/reconciler.go | 14 ++++++++------ .../registry/reconciler/reconciler_test.go | 14 ++++++++------ .../pkg/controller/bundle/bundle_unpacker.go | 3 +++ .../registry/reconciler/reconciler.go | 14 ++++++++------ 6 files changed, 48 insertions(+), 18 deletions(-) diff --git a/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go b/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go index 531c6bdde6..185a3726a7 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go +++ b/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go @@ -157,6 +157,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -182,6 +183,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -210,6 +212,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ diff --git a/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker_test.go b/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker_test.go index b0d2f368b5..cca9371c3a 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker_test.go +++ b/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker_test.go @@ -267,6 +267,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -292,6 +293,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -320,6 +322,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ @@ -498,6 +501,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -523,6 +527,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -551,6 +556,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ @@ -769,6 +775,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -794,6 +801,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -822,6 +830,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ @@ -1035,6 +1044,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -1060,6 +1070,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -1088,6 +1099,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ @@ -1270,6 +1282,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -1295,6 +1308,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -1323,6 +1337,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ @@ -1516,6 +1531,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -1541,6 +1557,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -1569,6 +1586,7 @@ func TestConfigMapUnpacker(t *testing.T) { Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ diff --git a/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go b/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go index b7c0e10894..77b5096038 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go +++ b/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go @@ -279,11 +279,12 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s MountPath: catalogPath, } pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ - Name: "extract-utilities", - Image: utilImage, - Command: []string{"cp"}, - Args: []string{"/bin/copy-content", fmt.Sprintf("%s/copy-content", utilitiesPath)}, - VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount}, + Name: "extract-utilities", + Image: utilImage, + Command: []string{"cp"}, + Args: []string{"/bin/copy-content", fmt.Sprintf("%s/copy-content", utilitiesPath)}, + VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount}, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, corev1.Container{ Name: "extract-content", Image: img, @@ -295,7 +296,8 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s "--cache.from=" + grpcPodConfig.ExtractContent.CacheDir, "--cache.to=" + fmt.Sprintf("%s/cache", catalogPath), }, - VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount, contentVolumeMount}, + VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount, contentVolumeMount}, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }) pod.Spec.Containers[0].Image = opmImg diff --git a/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler_test.go b/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler_test.go index 8bedf21ce3..f86aac77fd 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler_test.go +++ b/staging/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler_test.go @@ -277,7 +277,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "2AHzz8IDqQLwPsDyu4UjUmnROr4E59PMKm9OCm", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "5MSUJs07MqD3fl9supmPaRNxD9N6tK8Bjo4OFl", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -293,11 +293,12 @@ func TestPodExtractContent(t *testing.T) { }, InitContainers: []corev1.Container{ { - Name: "extract-utilities", - Image: "utilImage", - Command: []string{"cp"}, - Args: []string{"/bin/copy-content", "/utilities/copy-content"}, - VolumeMounts: []corev1.VolumeMount{{Name: "utilities", MountPath: "/utilities"}}, + Name: "extract-utilities", + Image: "utilImage", + Command: []string{"cp"}, + Args: []string{"/bin/copy-content", "/utilities/copy-content"}, + VolumeMounts: []corev1.VolumeMount{{Name: "utilities", MountPath: "/utilities"}}, + TerminationMessagePolicy: "FallbackToLogsOnError", }, { Name: "extract-content", @@ -314,6 +315,7 @@ func TestPodExtractContent(t *testing.T) { {Name: "utilities", MountPath: "/utilities"}, {Name: "catalog-content", MountPath: "/extracted-catalog"}, }, + TerminationMessagePolicy: "FallbackToLogsOnError", }, }, Containers: []corev1.Container{ diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go index 531c6bdde6..185a3726a7 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go @@ -157,6 +157,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, InitContainers: []corev1.Container{ @@ -182,6 +183,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, { Name: "pull", @@ -210,6 +212,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Drop: []corev1.Capability{"ALL"}, }, }, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, }, Volumes: []corev1.Volume{ diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go index b7c0e10894..77b5096038 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler/reconciler.go @@ -279,11 +279,12 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s MountPath: catalogPath, } pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ - Name: "extract-utilities", - Image: utilImage, - Command: []string{"cp"}, - Args: []string{"/bin/copy-content", fmt.Sprintf("%s/copy-content", utilitiesPath)}, - VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount}, + Name: "extract-utilities", + Image: utilImage, + Command: []string{"cp"}, + Args: []string{"/bin/copy-content", fmt.Sprintf("%s/copy-content", utilitiesPath)}, + VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount}, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }, corev1.Container{ Name: "extract-content", Image: img, @@ -295,7 +296,8 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s "--cache.from=" + grpcPodConfig.ExtractContent.CacheDir, "--cache.to=" + fmt.Sprintf("%s/cache", catalogPath), }, - VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount, contentVolumeMount}, + VolumeMounts: []corev1.VolumeMount{utilitiesVolumeMount, contentVolumeMount}, + TerminationMessagePolicy: corev1.TerminationMessageFallbackToLogsOnError, }) pod.Spec.Containers[0].Image = opmImg