fix: OpenTelemetryCollector health check shows 0/0 for mode: daemonset (#26391)

Signed-off-by: tank.500m <tank.500m@kakaocorp.com>
This commit is contained in:
tank.500m 2026-03-09 04:07:42 +09:00 committed by GitHub
parent 560d428381
commit 472d50cb19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View file

@ -14,8 +14,16 @@ if obj.status ~= nil then
total = tonumber(total)
if ready == 0 then
hs.status = "Degraded"
hs.message = "No replicas are ready"
-- DaemonSet desiredNumberScheduled is based on eligible nodes.
-- 0/0 is valid when no nodes match; treat as Healthy.
-- https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/#how-daemon-pods-are-scheduled
if obj.spec ~= nil and obj.spec.mode == "daemonset" and total == 0 then
hs.status = "Healthy"
hs.message = "DaemonSet has no eligible nodes (0/0)"
else
hs.status = "Degraded"
hs.message = "No replicas are ready"
end
elseif ready == total then
hs.status = "Healthy"
hs.message = "All replicas are ready"

View file

@ -3,6 +3,10 @@ tests:
status: Healthy
message: "All replicas are ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Healthy
message: "DaemonSet has no eligible nodes (0/0)"
inputPath: testdata/daemonset-no-eligible-node.yaml
- healthStatus:
status: Degraded
message: "No replicas are ready"

View file

@ -0,0 +1,14 @@
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: test-collector-daemonset-no-eligible-node
namespace: default
spec:
mode: daemonset
status:
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.124.1
scale:
replicas: 0
selector: app.kubernetes.io/component=opentelemetry-collector
statusReplicas: 0/0
version: 0.124.1