Skip to content

🐛 [WATCHER] Reconcile store containers on Docker event stream reconnect - #1576

Merged
fmartinou merged 1 commit into
mainfrom
fix/1575_docker-events-reconnect-reconcile
Nov 22, 2026
Merged

fmartinou merged 1 commit into
mainfrom
fix/1575_docker-events-reconnect-reconcile

Conversation

@fmartinou

Copy link
Copy Markdown
Collaborator

Problem

When the Docker watcher's event stream drops (for example when a Docker socket proxy container such as wollomatic/socket-proxy is recreated during an update), handleEventsStreamTerminated() schedules a reconnect via scheduleEventsReconnect(). When listenDockerEvents() opens a fresh stream via dockerApi.getEvents(), Docker does not replay events emitted during the disconnect gap, and the store was never reconciled afterward.

As a result, missed destroy / start events left stale container entries (old ID, old tag, updateAvailable: true) in the store until the next scheduled cron run.

Fixes #1575

Solution

  • Track successful Docker event stream connections with hasConnectedEvents in app/watchers/providers/docker/Docker.ts.
  • On a successful getEvents() callback in listenDockerEvents(), attach the new stream listeners and trigger reconcileStoreContainers('reconnect') whenever recovering from a previous stream (hasConnectedEvents) or after prior failed connection attempt(s) (eventsReconnectAttempts > 0). Clean initial connections skip redundant reconciliation because init() already runs startup reconciliation.
  • Parameterize reconcileStoreContainers(reason: 'startup' | 'reconnect' = 'startup') so logs accurately reflect startup vs. reconnect reconciliation.
  • Guard reconcileStoreContainers() against isDeregistered (at entry, after listContainers(), and inside the prune/add loops) and serialize/coalesce concurrent reconciliation calls so rapid reconnects cannot run overlapping passes or drop follow-up changes.
  • Handle promise rejections cleanly in listenDockerEvents().
  • Add a changelog entry in website/docs/changelog/next.md.

Validation

  • Added unit tests in app/watchers/providers/docker/Docker.test.ts covering:
    • Clean initial connection does not redundantly trigger reconcileStoreContainers().
    • Reconnection after stream error and end triggers reconcileStoreContainers('reconnect') and reconciles missed container removals and additions.
    • Retry connection succeeding after initial getEvents failure (eventsReconnectAttempts > 0) triggers reconcileStoreContainers('reconnect').
    • Deregistered watcher skips reconciliation on reconnect and aborts cleanly if deregistered mid-flight.
    • Reconciliation failures are caught and logged without unhandled promise rejections.
    • Overlapping reconcileStoreContainers() calls are serialized and coalesced.
  • Local gates passed:
    • cd app && npm test (134 suites / 3042 tests passed; Docker.ts coverage improved to 90.52% stmts / 86.30% branches / 94.50% funcs / 90.63% lines)
    • cd app && npm run lint (0 errors)
    • cd app && npm run build (clean TypeScript build)
    • cd website && npm run lint:docs (Markdownlint + CSpell passed with 0 issues)
    • cd website && npm run build (clean Docusaurus build)

@fmartinou
fmartinou merged commit c4a5ab6 into main Nov 22, 2026
21 checks passed
@fmartinou
fmartinou deleted the fix/1575_docker-events-reconnect-reconcile branch November 22, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant