Skip to content

container: resubscribe to the docker events stream - #1608

Open
cvas22 wants to merge 2 commits into
falcosecurity:mainfrom
cvas22:fix/1603-docker-events-resubscribe
Open

cvas22 wants to merge 2 commits into
falcosecurity:mainfrom
cvas22:fix/1603-docker-events-resubscribe

Conversation

@cvas22

@cvas22 cvas22 commented Nov 4, 2026 •

Copy link
Copy Markdown

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area plugins

What this PR does / why we need it:

dockerEngine.Listen subscribes to the events API once and ignores the error channel. The docker client reports a broken stream on that channel and then stops, without closing the messages channel. After a dockerd restart the plugin therefore never sees another create, start or destroy event, and containers created afterwards have no name or image on their first events.

The listener now also waits on the error channel, and when the stream ends while the context is alive it resubscribes after a backoff that starts at one second and doubles up to thirty, reusing the bounds and resubscribeWait from the CRI fix in #1502. A closed messages channel is treated the same way.

This does not re-list running containers after a reconnect, so a container created while the daemon was down is not picked up. As in #1502, I left that out because it needs a call on replaying containers the plugin may already know about.

Which issue(s) this PR fixes:

Fixes #1603

Notes:

TestDockerListenerResubscribesAfterStreamEnds runs the real Listen against a fake daemon whose first event stream ends with no events and whose second serves a create event. It fails without the change (timed out waiting for the event) and passes with it. I ran it with go test -tags containers_image_openpgp,exclude_graphdriver_btrfs,btrfs_noversion,exclude_graphdriver_devicemapper ./pkg/container -run 'TestDockerListenerResubscribes|ListenerShutdown' in a Linux container. TestDocker needs a live Docker daemon and was not run.

Does this PR introduce a user-facing change?:

fix(container): resume Docker event monitoring after daemon restarts or event-stream interruptions

@poiana

poiana commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cvas22
Once this PR has been reviewed and has the lgtm label, please assign deepskyblue86 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana

poiana commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Welcome @cvas22! It looks like this is your first PR to falcosecurity/plugins 🎉

cvas22 and others added 2 commits November 6, 2026 10:53
Fixes: falcosecurity#1603
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
@cvas22
cvas22 force-pushed the fix/1603-docker-events-resubscribe branch from 2c8d6e3 to 46c8d70 Compare November 6, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[container] docker engine does not resubscribe to events after dockerd restarts

3 participants