-
Notifications
You must be signed in to change notification settings - Fork 560
Description
Component(s)
collector
What happened?
Description
When using HPA with OpenTelemetryCollector, the deployment doesn't scale when HPA decides it needs more replicas. The issue is that GetInitialReplicas() always returns MinReplicas when autoscaler is configured, ignoring the Spec.Replicas field that HPA modifies.
opentelemetry-operator/internal/manifests/manifestutils/replicas.go
Lines 10 to 15 in 2584188
func GetInitialReplicas(otelCol v1beta1.OpenTelemetryCollector) *int32 { | |
if otelCol.Spec.Autoscaler != nil && otelCol.Spec.Autoscaler.MinReplicas != nil { | |
return otelCol.Spec.Autoscaler.MinReplicas | |
} | |
return otelCol.Spec.Replicas | |
} |
Steps to Reproduce
-
Create an OpenTelemetryCollector with autoscaler configuration:
apiVersion: opentelemetry.io/v1beta1 kind: OpenTelemetryCollector metadata: name: backend-traces namespace: monitoring spec: autoscaler: minReplicas: 3 maxReplicas: 6 targetCPUUtilization: 80 targetMemoryUtilization: 50 # ... rest of collector config
-
Check HPA status after load:
❯ k get hpa backend-traces-collector NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE backend-traces-collector OpenTelemetryCollector/backend-traces 62%/50%, 42%/80% 3 6 5 386d
-
Check deployment replicas:
❯ k get deployment backend-traces-collector -o jsonpath='{.spec.replicas}' 3⏎
-
Check OpenTelemetryCollector spec.replicas:
❯ k get otelcol backend-traces -o jsonpath='{.spec.replicas}' 5⏎
-
Verify the issue:
❯ k get pods -l app.kubernetes.io/name=backend-traces-collector NAME READY STATUS RESTARTS AGE backend-traces-collector-59f8cbdbcb-grstd 1/1 Running 0 19h backend-traces-collector-59f8cbdbcb-k6268 1/1 Running 0 3h14m backend-traces-collector-59f8cbdbcb-rqvhg 1/1 Running 0 19h
Expected Result
When HPA decides it needs more replicas (e.g. 5), the deployment should scale to 5 pods, respecting HPA's decision.
Actual Result
Deployment stays at MinReplicas (3) even when HPA shows higher desired replicas. GetInitialReplicas() always returns MinReplicas when autoscaler is configured, preventing HPA from working properly.
Kubernetes Version
v1.29.4
Operator version
v0.135.0
Collector version
v0.135.0
Environment information
Environment
OS: Ubuntu 20.04.5 LTS (Kubernetes cluster nodes)
Log output
{"level":"DEBUG","timestamp":"2025-09-30T18:53:21Z","logger":"controllers.OpenTelemetryCollector","message":"desired has been updated","opentelemetrycollector":{"name":"backend-traces","namespace":"monitoring"},"object_name":"backend-traces-collector","object_kind":"&TypeMeta{Kind:,APIVersion:,}"}
{"level":"DEBUG","timestamp":"2025-09-30T18:53:21Z","logger":"events","message":"applied status changes","type":"Normal","object":{"kind":"OpenTelemetryCollector","namespace":"monitoring","name":"backend-traces","uid":"ee182001-1c2a-453b-aed4-097f47492ead","apiVersion":"opentelemetry.io/v1beta1","resourceVersion":"2062985166"},"reason":"Info"}
Additional context
This issue was previously discussed in #4255 (comment)
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1
or me too
, to help us triage it. Learn more here.