From c7732f010f09be756cb2f65e0f04fba2117b2899 Mon Sep 17 00:00:00 2001 From: Jordan Keister Date: Tue, 8 Jul 2025 09:32:18 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20add=20catalog-operator=20control?= =?UTF-8?q?-plane-specific=20tolerations=20to=20unpack=20jobs=20(#3606)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add catalog-operator control-plane-specific tolerations to unpack jobs Signed-off-by: grokspawn * refactored common in test Signed-off-by: grokspawn --------- Signed-off-by: grokspawn Upstream-repository: operator-lifecycle-manager Upstream-commit: 57e6b8c8b381be1d6432718905b9825495836470 --- .../pkg/controller/bundle/bundle_unpacker.go | 19 ++ .../controller/bundle/bundle_unpacker_test.go | 180 +++++------------- .../pkg/controller/bundle/bundle_unpacker.go | 19 ++ 3 files changed, 86 insertions(+), 132 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 d16ae7d0d1..ad300b7c88 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go +++ b/staging/operator-lifecycle-manager/pkg/controller/bundle/bundle_unpacker.go @@ -233,6 +233,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string "kubernetes.io/os": "linux", }, Tolerations: []corev1.Toleration{ + // arch-specific tolerations { Key: "kubernetes.io/arch", Value: "amd64", @@ -253,6 +254,24 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Value: "s390x", Operator: "Equal", }, + // control-plane-specific tolerations + { + Key: "node-role.kubernetes.io/master", + Operator: "Exists", + Effect: "NoSchedule", + }, + { + Key: "node.kubernetes.io/unreachable", + Operator: "Exists", + Effect: "NoExecute", + TolerationSeconds: ptr.To[int64](120), + }, + { + Key: "node.kubernetes.io/not-ready", + Operator: "Exists", + Effect: "NoExecute", + TolerationSeconds: ptr.To[int64](120), + }, }, }, }, 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 d36bba773b..2a55fcff83 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 @@ -59,6 +59,48 @@ func TestConfigMapUnpacker(t *testing.T) { customAnnotationDuration := 2 * time.Minute customAnnotationTimeoutSeconds := int64(customAnnotationDuration.Seconds()) + podTolerations := []corev1.Toleration{ + // arch-specific tolerations + { + Key: "kubernetes.io/arch", + Value: "amd64", + Operator: "Equal", + }, + { + Key: "kubernetes.io/arch", + Value: "arm64", + Operator: "Equal", + }, + { + Key: "kubernetes.io/arch", + Value: "ppc64le", + Operator: "Equal", + }, + { + Key: "kubernetes.io/arch", + Value: "s390x", + Operator: "Equal", + }, + // control-plane-specific tolerations + { + Key: "node-role.kubernetes.io/master", + Operator: "Exists", + Effect: "NoSchedule", + }, + { + Key: "node.kubernetes.io/unreachable", + Operator: "Exists", + Effect: "NoExecute", + TolerationSeconds: ptr.To[int64](120), + }, + { + Key: "node.kubernetes.io/not-ready", + Operator: "Exists", + Effect: "NoExecute", + TolerationSeconds: ptr.To[int64](120), + }, + } + type fields struct { objs []runtime.Object crs []runtime.Object @@ -342,28 +384,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []corev1.Toleration{ - { - Key: "kubernetes.io/arch", - Value: "amd64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "arm64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "ppc64le", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "s390x", - Operator: "Equal", - }, - }, + Tolerations: podTolerations, }, }, }, @@ -576,28 +597,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []corev1.Toleration{ - { - Key: "kubernetes.io/arch", - Value: "amd64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "arm64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "ppc64le", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "s390x", - Operator: "Equal", - }, - }, + Tolerations: podTolerations, }, }, }, @@ -850,28 +850,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []corev1.Toleration{ - { - Key: "kubernetes.io/arch", - Value: "amd64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "arm64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "ppc64le", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "s390x", - Operator: "Equal", - }, - }, + Tolerations: podTolerations, }, }, }, @@ -1119,28 +1098,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []corev1.Toleration{ - { - Key: "kubernetes.io/arch", - Value: "amd64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "arm64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "ppc64le", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "s390x", - Operator: "Equal", - }, - }, + Tolerations: podTolerations, }, }, }, @@ -1358,28 +1316,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []corev1.Toleration{ - { - Key: "kubernetes.io/arch", - Value: "amd64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "arm64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "ppc64le", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "s390x", - Operator: "Equal", - }, - }, + Tolerations: podTolerations, }, }, }, @@ -1610,28 +1547,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []corev1.Toleration{ - { - Key: "kubernetes.io/arch", - Value: "amd64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "arm64", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "ppc64le", - Operator: "Equal", - }, - { - Key: "kubernetes.io/arch", - Value: "s390x", - Operator: "Equal", - }, - }, + Tolerations: podTolerations, }, }, }, 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 d16ae7d0d1..ad300b7c88 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 @@ -233,6 +233,7 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string "kubernetes.io/os": "linux", }, Tolerations: []corev1.Toleration{ + // arch-specific tolerations { Key: "kubernetes.io/arch", Value: "amd64", @@ -253,6 +254,24 @@ func (c *ConfigMapUnpacker) job(cmRef *corev1.ObjectReference, bundlePath string Value: "s390x", Operator: "Equal", }, + // control-plane-specific tolerations + { + Key: "node-role.kubernetes.io/master", + Operator: "Exists", + Effect: "NoSchedule", + }, + { + Key: "node.kubernetes.io/unreachable", + Operator: "Exists", + Effect: "NoExecute", + TolerationSeconds: ptr.To[int64](120), + }, + { + Key: "node.kubernetes.io/not-ready", + Operator: "Exists", + Effect: "NoExecute", + TolerationSeconds: ptr.To[int64](120), + }, }, }, },