Repository navigation
🐛 [WATCHER] Reconcile store containers on Docker event stream reconnect - #1576
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the Docker watcher's event stream drops (for example when a Docker socket proxy container such as
wollomatic/socket-proxyis recreated during an update),handleEventsStreamTerminated()schedules a reconnect viascheduleEventsReconnect(). WhenlistenDockerEvents()opens a fresh stream viadockerApi.getEvents(), Docker does not replay events emitted during the disconnect gap, and the store was never reconciled afterward.As a result, missed
destroy/startevents left stale container entries (old ID, old tag,updateAvailable: true) in the store until the next scheduled cron run.Fixes #1575
Solution
hasConnectedEventsinapp/watchers/providers/docker/Docker.ts.getEvents()callback inlistenDockerEvents(), attach the new stream listeners and triggerreconcileStoreContainers('reconnect')whenever recovering from a previous stream (hasConnectedEvents) or after prior failed connection attempt(s) (eventsReconnectAttempts > 0). Clean initial connections skip redundant reconciliation becauseinit()already runs startup reconciliation.reconcileStoreContainers(reason: 'startup' | 'reconnect' = 'startup')so logs accurately reflect startup vs. reconnect reconciliation.reconcileStoreContainers()againstisDeregistered(at entry, afterlistContainers(), and inside the prune/add loops) and serialize/coalesce concurrent reconciliation calls so rapid reconnects cannot run overlapping passes or drop follow-up changes.listenDockerEvents().website/docs/changelog/next.md.Validation
app/watchers/providers/docker/Docker.test.tscovering:reconcileStoreContainers().errorandendtriggersreconcileStoreContainers('reconnect')and reconciles missed container removals and additions.getEventsfailure (eventsReconnectAttempts > 0) triggersreconcileStoreContainers('reconnect').reconcileStoreContainers()calls are serialized and coalesced.cd app && npm test(134 suites / 3042 tests passed;Docker.tscoverage 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)