Skip to content

Commit

Permalink
flow: only use component health when component implements component.H…
Browse files Browse the repository at this point in the history
…ealthComponent (#3740)

* Revert "Default back to healthy when a component does not implement component.HealthComponent (#3558)"

This reverts commit b2f8992. The commit
introduced a bug where the "default health" message was always returned
for healthy components, overriding the message informing the user when
the last time the component evaluated was.

* flow: only use component health if component exposes health

This commit offers an alernative approach to #3558, where the overall
health of a component only considers the component implementation of
health if that component implements the component.HealthComponent
interface.

Without this commit, the zero value of component.Health was always
returned, considering the health of every component as being "unknown."
  • Loading branch information
rfratto authored May 1, 2023
1 parent 630613d commit ff2ca95
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Main (unreleased)

- Disable node_exporter on Windows systems (@jkroepke)

### Bugfixes

- Fix issue where component evaluation time was overridden by a "default
health" message. (@rfratto)

### Other changes

- Add metrics when clustering mode is enabled. (@rfratto)
Expand Down
10 changes: 0 additions & 10 deletions component/component_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ var (
_ encoding.TextUnmarshaler = (*HealthType)(nil)
)

// Default Health returns a copy of the default health for use when a component
// does not implement HealthComponent.
func DefaultHealth() Health {
return Health{
Health: HealthTypeHealthy,
Message: "default health",
UpdateTime: time.Now(),
}
}

const (
// HealthTypeUnknown is the initial health of components, set when they're
// first created.
Expand Down
9 changes: 3 additions & 6 deletions pkg/flow/internal/controller/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,14 @@ func (cn *ComponentNode) CurrentHealth() component.Health {
var (
runHealth = cn.runHealth
evalHealth = cn.evalHealth

componentHealth component.Health
)

if hc, ok := cn.managed.(component.HealthComponent); ok {
componentHealth = hc.CurrentHealth()
} else {
componentHealth = component.DefaultHealth()
componentHealth := hc.CurrentHealth()
return component.LeastHealthy(runHealth, evalHealth, componentHealth)
}

return component.LeastHealthy(runHealth, evalHealth, componentHealth)
return component.LeastHealthy(runHealth, evalHealth)
}

// DebugInfo returns debugging information from the managed component (if any).
Expand Down

0 comments on commit ff2ca95

Please sign in to comment.