From 7ce873d6000baed9fb26bbae7170bf347d1f951a Mon Sep 17 00:00:00 2001 From: grokspawn Date: Mon, 7 Jul 2025 15:25:01 -0500 Subject: [PATCH 1/2] add catalog-operator control-plane-specific tolerations to unpack jobs Signed-off-by: grokspawn --- pkg/controller/bundle/bundle_unpacker.go | 19 ++++++++++ pkg/controller/bundle/bundle_unpacker_test.go | 38 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/pkg/controller/bundle/bundle_unpacker.go b/pkg/controller/bundle/bundle_unpacker.go index b8ee90700c..698119af6f 100644 --- a/pkg/controller/bundle/bundle_unpacker.go +++ b/pkg/controller/bundle/bundle_unpacker.go @@ -234,6 +234,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", @@ -254,6 +255,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/pkg/controller/bundle/bundle_unpacker_test.go b/pkg/controller/bundle/bundle_unpacker_test.go index b0502fc316..d05dd43c83 100644 --- a/pkg/controller/bundle/bundle_unpacker_test.go +++ b/pkg/controller/bundle/bundle_unpacker_test.go @@ -346,6 +346,7 @@ func TestConfigMapUnpacker(t *testing.T) { "kubernetes.io/os": "linux", }, Tolerations: []corev1.Toleration{ + // arch-specific tolerations { Key: "kubernetes.io/arch", Value: "amd64", @@ -366,6 +367,24 @@ func TestConfigMapUnpacker(t *testing.T) { 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), + }, }, }, }, @@ -1132,6 +1151,7 @@ func TestConfigMapUnpacker(t *testing.T) { "kubernetes.io/os": "linux", }, Tolerations: []corev1.Toleration{ + // arch-specific tolerations { Key: "kubernetes.io/arch", Value: "amd64", @@ -1152,6 +1172,24 @@ func TestConfigMapUnpacker(t *testing.T) { 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), + }, }, }, }, From b0a5526f2622434712ebe3e87ed6c55d89cd98ee Mon Sep 17 00:00:00 2001 From: grokspawn Date: Mon, 7 Jul 2025 16:04:28 -0500 Subject: [PATCH 2/2] refactored common in test Signed-off-by: grokspawn --- pkg/controller/bundle/bundle_unpacker_test.go | 218 ++++-------------- 1 file changed, 48 insertions(+), 170 deletions(-) diff --git a/pkg/controller/bundle/bundle_unpacker_test.go b/pkg/controller/bundle/bundle_unpacker_test.go index d05dd43c83..312037bf2a 100644 --- a/pkg/controller/bundle/bundle_unpacker_test.go +++ b/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 @@ -345,47 +387,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []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), - }, - }, + Tolerations: podTolerations, }, }, }, @@ -601,28 +603,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, }, }, }, @@ -878,28 +859,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, }, }, }, @@ -1150,47 +1110,7 @@ func TestConfigMapUnpacker(t *testing.T) { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - Tolerations: []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), - }, - }, + Tolerations: podTolerations, }, }, }, @@ -1411,28 +1331,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, }, }, }, @@ -1666,28 +1565,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, }, }, },