fix(events): update container health status on all transitions#297
Conversation
Docker emits health_status events with actions like "health_status: healthy", "health_status: starting", and "health_status: unhealthy". The match arms only covered healthy/unhealthy, so "starting" → "healthy" transitions were dropped. The handler also looked for a "health_status" key in actor.attributes that Docker does not populate, so even matching events failed to parse. Match any action starting with "health_status" and parse the status from the action string itself, falling back to attributes and then inspect_container. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Code ReviewOverviewThis PR fixes a real bug: health status was stuck on "starting" because the match arm didn't include Issues1. Minor: // current
let health = match health {
Some(h) => Some(h),
None => { ... }
};This is just let health = health.or_else(|| {
if let Ok(inspect) = self.docker.inspect_container(...).await {
...
} else {
None
}
});2. Minor: The inspect fallback (unchanged from original) relies on 3. Edge case: Docker can emit What looks good
VerdictThe core fix is correct and an improvement. Items 1 and 2 are minor style/robustness issues; item 3 is a low-priority edge case. Good to merge as-is with optional follow-up on the edge case. |
Code ReviewOverviewThis PR fixes a real bug: Docker health events use actions like What works well
IssuesStyle: // current
let health = match health {
Some(h) => Some(h),
None => { ... }
};
// simpler
let health = match health {
Some(_) => health,
None => { ... }
};Minor nit, but wrapping No automated tests added The bug is in assert_eq!("health_status: healthy".parse(), Ok(HealthStatus::Healthy));
assert_eq!("health_status: unhealthy".parse(), Ok(HealthStatus::Unhealthy));
assert_eq!("health_status: starting".parse(), Ok(HealthStatus::Starting));Manual verification unchecked The test plan has the VerdictThe fix is correct and the logic is sound. Two things before merging: confirm the manual test, and optionally add the unit test above to document the |
Docker Image Built Successfully |
Summary
starting → healthytransition event was never handled.health_status: healthy,health_status: starting,health_status: unhealthy. The match only covered healthy/unhealthy, dropping the rest.actor.attributes["health_status"], which Docker doesn't populate, so even matched events failed to parse.Fix
health_statusand pass the action string to the handler.FromStrsubstring matcher), falling back to attributes and theninspect_container.Test plan
cargo fmt --checkcargo clippycargo test🤖 Generated with Claude Code