Repository navigation
✨ feat(notifications): health-status event notifications (#198) - #505
Conversation
- ✨ feat(watcher): capture State.Health on the event leg (new health_status event type, changed-flag wiring) and the cron leg (unconditional store-refresh inspect so health is read every cycle) - ✨ feat(store): edge-triggered container-unhealthy transition detection — restart-reset via details.startedAt on both observations, no fire without an observed baseline, rollback containers excluded - ✨ feat(triggers): container-unhealthy notification rule (disabled by default), simple + batch templates, threshold-bypassing dispatch through the existing lifecycle-event pipeline - ✨ feat(audit): container-unhealthy audit rows with 5-minute per-container dedupe and Prometheus audit counter - 🐛 fix(model): out-of-enum Docker health values normalize to undefined at the model boundary instead of throwing mid-update - ✅ test: full 100% coverage across model, watcher, store, event, trigger, notification, and audit suites - 📝 docs: triggers docs rule/event tables, CHANGELOG entry, README roadmap row, en locale entry Ref: Discussion #198
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughAdds Docker health-state normalization and persistence across inspection, event, and store flows. Eligible transitions into 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/watchers/providers/docker/docker-image-details-orchestration.ts (1)
405-430: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick winAvoid the extra inspect on the stored-container path.
watch()is only reached fromwatchFromCron(), so this adds one Docker round-trip per tracked container on every scheduled scan. Reuse the inspect already flowing through the refresh path instead of callinginspectDiscoveredContainer()again.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/watchers/providers/docker/docker-image-details-orchestration.ts` around lines 405 - 430, The stored-container refresh path performs a redundant Docker inspect. Update refreshContainerAlreadyInStore to reuse the inspect result already supplied through its context or refresh flow, and remove the direct inspectDiscoveredContainer call while preserving the existing successful-inspect health normalization and failure behavior.
🧹 Nitpick comments (2)
app/watchers/providers/docker/docker-image-details-orchestration.ts (1)
405-414: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDead
containerInspectfield inRefreshContainerAlreadyInStoreContext.
containerInspectis passed into the context at the call site (line 723) but never destructured/used insiderefreshContainerAlreadyInStore— the function always re-fetches its own copy at line 427. This field is vestigial and misleading; drop it from the type/call site, or if the intent was to allow callers to skip a duplicate inspect, wire it through instead of ignoring it.♻️ Suggested cleanup
if (containerInStore !== undefined && containerInStore.error === undefined) { return refreshContainerAlreadyInStore({ watcher, container, dockerContainerName, labelOverrides, helpers, runtimeDetailsFromSummary, containerInStore, - containerInspect: undefined, }); }Also applies to: 693-725
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/watchers/providers/docker/docker-image-details-orchestration.ts` around lines 405 - 414, Remove the unused containerInspect field from RefreshContainerAlreadyInStoreContext and stop passing it at the refreshContainerAlreadyInStore call site. Keep the function’s existing container inspection behavior unchanged unless the field is intentionally wired through to avoid the duplicate fetch.app/event/audit-subscriptions.ts (1)
160-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winInclude
previousHealthin the audit record'sdetails.Other handlers (
update-failed,security-alert) populatedetailswith useful context; this one omitspayload.previousHealth, losing troubleshooting context available on the payload.♻️ Proposed fix
auditStore.insertAudit({ id: '', timestamp: new Date().toISOString(), action: 'container-unhealthy', containerName: payload.containerName, status: 'error', + details: payload.previousHealth ? `previousHealth: ${payload.previousHealth}` : undefined, });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/event/audit-subscriptions.ts` around lines 160 - 180, Update the audit record created in the registerContainerHealthTransition handler to include payload.previousHealth in its details field, preserving the existing container-unhealthy action, status, deduplication, and counter behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/store/container.ts`:
- Around line 738-748: Move the existing.health === undefined guard ahead of the
restarted calculation so unobserved health returns undefined without evaluating
startedAt differences. Preserve restart detection only for containers with a
recorded health value, and add a regression test covering differing startedAt
values with undefined existing health and no entered-unhealthy notification.
In `@content/docs/current/configuration/triggers/index.mdx`:
- Line 185: Update the container-unhealthy trigger description to clarify that
it may fire again when a still-unhealthy container restarts and its
details.startedAt value changes, while retaining the existing behavior for
continuous unhealthy state without a restart.
---
Outside diff comments:
In `@app/watchers/providers/docker/docker-image-details-orchestration.ts`:
- Around line 405-430: The stored-container refresh path performs a redundant
Docker inspect. Update refreshContainerAlreadyInStore to reuse the inspect
result already supplied through its context or refresh flow, and remove the
direct inspectDiscoveredContainer call while preserving the existing
successful-inspect health normalization and failure behavior.
---
Nitpick comments:
In `@app/event/audit-subscriptions.ts`:
- Around line 160-180: Update the audit record created in the
registerContainerHealthTransition handler to include payload.previousHealth in
its details field, preserving the existing container-unhealthy action, status,
deduplication, and counter behavior.
In `@app/watchers/providers/docker/docker-image-details-orchestration.ts`:
- Around line 405-414: Remove the unused containerInspect field from
RefreshContainerAlreadyInStoreContext and stop passing it at the
refreshContainerAlreadyInStore call site. Keep the function’s existing container
inspection behavior unchanged unless the field is intentionally wired through to
avoid the duplicate fetch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 898a5415-12c0-477b-829b-4ec874d6970c
⛔ Files ignored due to path filters (1)
CHANGELOG.mdis excluded by!CHANGELOG.md
📒 Files selected for processing (26)
README.mdapp/event/audit-subscriptions.test.tsapp/event/audit-subscriptions.tsapp/event/index.test.tsapp/event/index.tsapp/model/audit.d.tsapp/model/container.test.tsapp/model/container.tsapp/store/container.test.tsapp/store/container.tsapp/store/notification.test.tsapp/store/notification.tsapp/triggers/providers/Trigger.test.tsapp/triggers/providers/Trigger.tsapp/watchers/providers/docker/Docker.containers.details.test.tsapp/watchers/providers/docker/Docker.containers.test.tsapp/watchers/providers/docker/Docker.events.test.tsapp/watchers/providers/docker/container-event-update.test.tsapp/watchers/providers/docker/container-event-update.tsapp/watchers/providers/docker/docker-event-orchestration.test.tsapp/watchers/providers/docker/docker-events.test.tsapp/watchers/providers/docker/docker-events.tsapp/watchers/providers/docker/docker-image-details-orchestration.test.tsapp/watchers/providers/docker/docker-image-details-orchestration.tscontent/docs/current/configuration/triggers/index.mdxui/src/locales/en/listViews.json
review) - 🐛 fix(store): move the unobserved-baseline guard ahead of restart detection so a legacy record with no recorded health never fires on its first observed unhealthy state - ✨ feat(audit): include previous health in the container-unhealthy audit row details - 🔄 refactor(watcher): drop the dead containerInspect context field from the store-refresh path - 📝 docs(triggers): document the restart-episode re-notification exception - ✅ test: regressions for the guard ordering and both audit details branches
What
Implements the v1.6 roadmap commitment from Discussion #198: a new
container-unhealthynotification rule that fires your existing notification triggers the moment a container's Docker health check enters theunhealthystate.How it works
health_status(near-instant firing), and the cron refresh inspects every already-known container each cycle, so health is still captured while the events listener is disconnected/backing off or withDD_WATCHER_<name>_WATCHEVENTS=false.unhealthywithin the same container instantiation: never repeatedly while a container stays unhealthy, never on first observation with no baseline (fresh discovery/recreate, or store records predating health tracking), and a changeddetails.startedAton both observations marks a fast crash-loop as a genuinely new episode.update-applied/agent-disconnectprecedent): threshold bypassed, batch mode supported, per-containerdd.notification.include/dd.notification.excluderespected, outbox retry on provider failure. Remote-agent containers work via the existing store-forwarding path with zero agent-specific code.enabled: falsewith an empty trigger list, matching the agent-connectivity rules. Zero new env vars, zero new labels, zero per-provider config.container-unhealthyaudit rows (statuserror) with a 5-minute per-container dedupe window and the standard audit Prometheus counter.State.Health.Statusfrom a future Docker version normalizes toundefinedat the model boundary — unknown is not assumed unhealthy, and it can no longer throw mid-update.Docs
Triggers docs (rules table, dispatch behavior, event types), CHANGELOG
[Unreleased], README v1.6 roadmap row,enlocale entry for the Notifications view.Verification
Ref: Discussion #198
Changelog
container-unhealthynotification rule (disabled by default) with Dockerhealth_status-driven edge-triggered transitions.container-unhealthywith(was healthy)audit details whenpreviousHealthis available; increments Prometheus counters.details.startedAt, plus guards to avoid firing on first observation when no prior health baseline exists (legacy records).undefinedand updated Docker watcher/inspect flows + event filters to includehealth_status.Concerns
containerName; verify uniqueness/consistency for the intended audience.details.startedAtavailability and rollback-pattern matching; verify these edge cases in production-like data.