From 78f571d506be2f26a1cfc08b9efad0d56da8f9ec Mon Sep 17 00:00:00 2001 From: Ankita Thomas Date: Sun, 13 Sep 2026 17:29:29 -0400 Subject: [PATCH] add cpu limits to catalogsource pods Signed-off-by: Ankita Thomas --- .../registry/reconciler/reconciler.go | 5 +++ .../registry/reconciler/reconciler_test.go | 41 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/pkg/controller/registry/reconciler/reconciler.go b/pkg/controller/registry/reconciler/reconciler.go index d10d5992e5..5db88fd313 100644 --- a/pkg/controller/registry/reconciler/reconciler.go +++ b/pkg/controller/registry/reconciler/reconciler.go @@ -189,6 +189,11 @@ func Pod(source *operatorsv1alpha1.CatalogSource, name, opmImg, utilImage, img s corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + // enforce CPU limits to avoid node degradation due to CPU spikes + // on catalog cache building on startup + corev1.ResourceCPU: resource.MustParse("2"), + }, }, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(false), diff --git a/pkg/controller/registry/reconciler/reconciler_test.go b/pkg/controller/registry/reconciler/reconciler_test.go index fc6187a684..ad5c8cdce5 100644 --- a/pkg/controller/registry/reconciler/reconciler_test.go +++ b/pkg/controller/registry/reconciler/reconciler_test.go @@ -38,7 +38,7 @@ func TestPodMemoryTarget(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "cBESV2Miwqi3TX1KELgXItd7j206e4q6b21BnP", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "b3TgxOZKR9GWI3HsZUGul7EMYUKpXBazgJaBy2", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -80,6 +80,9 @@ func TestPodMemoryTarget(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(false), @@ -110,7 +113,7 @@ func TestPodMemoryTarget(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "22OBIOEoFxFjed27eJvvYzqL0TfdXsuapKoxsE", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "6I8q4ntU0mg0YDRUFqE4iTcpWAB36q6eHFwWhd", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -153,7 +156,9 @@ func TestPodMemoryTarget(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("5Mi"), }, - Limits: corev1.ResourceList{}, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(false), @@ -209,7 +214,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "cBESV2Miwqi3TX1KELgXItd7j206e4q6b21BnP", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "b3TgxOZKR9GWI3HsZUGul7EMYUKpXBazgJaBy2", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -251,6 +256,9 @@ func TestPodExtractContent(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(false), @@ -285,7 +293,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "30fzEky6rWPSaUHUtTN3mbl0SvE2PryXPIr090", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "8kD3A1vMnCYXEz5zdY2TUF5zWrKTiKVLPSUcRu", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -372,6 +380,9 @@ func TestPodExtractContent(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(true), @@ -406,7 +417,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "57eMKS6v8du5evWOTeBJEFYx7r5udVxvhEQpLB", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "8OkzMFWKKYyt5gqJvM01VuNmlSzzLXymyPrXVF", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -495,6 +506,9 @@ func TestPodExtractContent(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, SecurityContext: &corev1.SecurityContext{ ReadOnlyRootFilesystem: ptr.To(true), @@ -522,7 +536,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "bfNQa9OTbkeciTpFoCgpKhNENGjVjY61PYAoYA", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "bDc9JN6M7lrPZ9WAke2iCgiMSvhxg1iOz28MCI", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -564,6 +578,9 @@ func TestPodExtractContent(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, ImagePullPolicy: image.InferImagePullPolicy("image"), SecurityContext: &corev1.SecurityContext{ @@ -605,7 +622,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "5CPn3qG7EdDS0mOX7AazM9Tt1RBtR6bjjMmmep", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "aDF279JF7kYO6HMGYcKsekOgv8APQPIuVKJuAP", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -696,6 +713,9 @@ func TestPodExtractContent(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, ImagePullPolicy: image.InferImagePullPolicy("image"), SecurityContext: &corev1.SecurityContext{ @@ -737,7 +757,7 @@ func TestPodExtractContent(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: "testns", - Labels: map[string]string{"olm.pod-spec-hash": "adSLBZw1o1geKStnSKaiQEubBnN4eqkHabCyHs", "olm.managed": "true"}, + Labels: map[string]string{"olm.pod-spec-hash": "1NOYbt10A4JQuURRyUwEHdnJgZ09GQnCCPm9Xv", "olm.managed": "true"}, Annotations: map[string]string{"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"}, }, Spec: corev1.PodSpec{ @@ -830,6 +850,9 @@ func TestPodExtractContent(t *testing.T) { corev1.ResourceCPU: resource.MustParse("10m"), corev1.ResourceMemory: resource.MustParse("50Mi"), }, + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2"), + }, }, ImagePullPolicy: image.InferImagePullPolicy("image"), SecurityContext: &corev1.SecurityContext{