diff --git a/.chloggen/add-collector-pool-healthy.yaml b/.chloggen/add-collector-pool-healthy.yaml new file mode 100755 index 0000000000..1bc8ca48ed --- /dev/null +++ b/.chloggen/add-collector-pool-healthy.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. collector, target allocator, auto-instrumentation, opamp, github action) +component: opamp + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add healthy field at collector pool level in opamp bridge heartbeat + +# One or more tracking issues related to the change +issues: [2936] + +# (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: diff --git a/cmd/operator-opamp-bridge/agent/agent.go b/cmd/operator-opamp-bridge/agent/agent.go index cab16f7728..792c2d23de 100644 --- a/cmd/operator-opamp-bridge/agent/agent.go +++ b/cmd/operator-opamp-bridge/agent/agent.go @@ -119,11 +119,17 @@ func (agent *Agent) generateCollectorPoolHealth() (map[string]*protobufs.Compone if err != nil { return nil, err } + + isPoolHealthy := true + for _, pod := range podMap { + isPoolHealthy = isPoolHealthy && pod.Healthy + } healthMap[key.String()] = &protobufs.ComponentHealth{ StartTimeUnixNano: uint64(col.ObjectMeta.GetCreationTimestamp().UnixNano()), StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()), Status: col.Status.Scale.StatusReplicas, ComponentHealthMap: podMap, + Healthy: isPoolHealthy, } } return healthMap, nil diff --git a/cmd/operator-opamp-bridge/agent/agent_test.go b/cmd/operator-opamp-bridge/agent/agent_test.go index d883e49965..75d533eae1 100644 --- a/cmd/operator-opamp-bridge/agent/agent_test.go +++ b/cmd/operator-opamp-bridge/agent/agent_test.go @@ -272,7 +272,7 @@ func TestAgent_getHealth(t *testing.T) { StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "testnamespace/collector": { - Healthy: false, // we're working with mocks so the status will never be reconciled. + Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", @@ -305,7 +305,7 @@ func TestAgent_getHealth(t *testing.T) { StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "testnamespace/collector": { - Healthy: false, // we're working with mocks so the status will never be reconciled. + Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", @@ -313,7 +313,7 @@ func TestAgent_getHealth(t *testing.T) { ComponentHealthMap: map[string]*protobufs.ComponentHealth{}, }, "testnamespace/other": { - Healthy: false, // we're working with mocks so the status will never be reconciled. + Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "", @@ -345,7 +345,7 @@ func TestAgent_getHealth(t *testing.T) { StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()), ComponentHealthMap: map[string]*protobufs.ComponentHealth{ "other/third": { - Healthy: false, // we're working with mocks so the status will never be reconciled. + Healthy: true, StartTimeUnixNano: collectorStartTime, LastError: "", Status: "",