Skip to content

Commit

Permalink
opamp bridge - set healthy bool at collector pool level (#2937)
Browse files Browse the repository at this point in the history
* set healthy bool at collector pool level

* add changelog
  • Loading branch information
jdcrouse authored May 8, 2024
1 parent e98b7a2 commit 84fc72a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
16 changes: 16 additions & 0 deletions .chloggen/add-collector-pool-healthy.yaml
Original file line number Diff line number Diff line change
@@ -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:
6 changes: 6 additions & 0 deletions cmd/operator-opamp-bridge/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cmd/operator-opamp-bridge/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -305,15 +305,15 @@ 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: "",
StatusTimeUnixNano: uint64(fakeClock.Now().UnixNano()),
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: "",
Expand Down Expand Up @@ -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: "",
Expand Down

0 comments on commit 84fc72a

Please sign in to comment.