From 9cf9e332c35890503871fe05bc182e18b40710d8 Mon Sep 17 00:00:00 2001 From: PeterSzegedi Date: Tue, 12 Sep 2023 15:34:43 +0100 Subject: [PATCH] Remove TargetAllocator resource defaults (#2040) * Remove TargetAllocator resource defaults * Add changelog entry * Update e2e test for target allocator * trigger tests * Add heads up for change of behaviour --- .chloggen/remove_ta_defaults.yaml | 16 ++++++++++++++++ apis/v1alpha1/opentelemetrycollector_webhook.go | 15 --------------- .../e2e/targetallocator-features/00-assert.yaml | 7 ------- 3 files changed, 16 insertions(+), 22 deletions(-) create mode 100755 .chloggen/remove_ta_defaults.yaml diff --git a/.chloggen/remove_ta_defaults.yaml b/.chloggen/remove_ta_defaults.yaml new file mode 100755 index 0000000000..af64a954f9 --- /dev/null +++ b/.chloggen/remove_ta_defaults.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove default cpu and mem requests and limits from target allocator to match otel-collector behaviour + +# One or more tracking issues related to the change +issues: [1914] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: To preserve the old behaviour for the case when the requests/limits were not explicitely set during the deployment, make sure to set the requests/limits of 100m/200m for CPU and 250Mi/500Mi for memory. diff --git a/apis/v1alpha1/opentelemetrycollector_webhook.go b/apis/v1alpha1/opentelemetrycollector_webhook.go index 0179c8559b..40b4df0506 100644 --- a/apis/v1alpha1/opentelemetrycollector_webhook.go +++ b/apis/v1alpha1/opentelemetrycollector_webhook.go @@ -18,8 +18,6 @@ import ( "fmt" autoscalingv2 "k8s.io/api/autoscaling/v2" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation" ctrl "sigs.k8s.io/controller-runtime" @@ -72,19 +70,6 @@ func (r *OpenTelemetryCollector) Default() { r.Spec.TargetAllocator.Replicas = &one } - if r.Spec.TargetAllocator.Enabled && r.Spec.TargetAllocator.Resources.Limits == nil { - r.Spec.TargetAllocator.Resources.Limits = corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("200m"), - corev1.ResourceMemory: resource.MustParse("500Mi"), - } - } - if r.Spec.TargetAllocator.Enabled && r.Spec.TargetAllocator.Resources.Requests == nil { - r.Spec.TargetAllocator.Resources.Requests = corev1.ResourceList{ - corev1.ResourceCPU: resource.MustParse("100m"), - corev1.ResourceMemory: resource.MustParse("250Mi"), - } - } - if r.Spec.MaxReplicas != nil || (r.Spec.Autoscaler != nil && r.Spec.Autoscaler.MaxReplicas != nil) { if r.Spec.Autoscaler == nil { r.Spec.Autoscaler = &AutoscalerSpec{} diff --git a/tests/e2e/targetallocator-features/00-assert.yaml b/tests/e2e/targetallocator-features/00-assert.yaml index 866654e112..d7676d9b1f 100644 --- a/tests/e2e/targetallocator-features/00-assert.yaml +++ b/tests/e2e/targetallocator-features/00-assert.yaml @@ -58,13 +58,6 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - resources: - limits: - cpu: 200m - memory: 500Mi - requests: - cpu: 100m - memory: 250Mi volumeMounts: - mountPath: /conf name: ta-internal