Repository navigation
fix(plugins/container): update docker containers on rename - #1602
Merged
Merged
Conversation
The docker listener only subscribed to the create, start and destroy events. docker compose creates a recreated container under a temporary `<old-id[:12]>_<name>` name and renames it before starting it, so with the default `create` hook the cached container kept the temporary name until Falco restarted; a `docker rename` was never picked up either. Always subscribe to the rename event, whatever hooks are attached, and re-inspect the container like on create and start. If the inspection fails, keep the cached metadata instead of replacing them with the minimum set. Signed-off-by: rajanpanth <rajan.pantha@samriddhicollege.edu.np>
Contributor
|
Welcome @rajanpanth! It looks like this is your first PR to falcosecurity/plugins 🎉 |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: leogr, rajanpanth The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Contributor
|
LGTM label has been added. DetailsGit tree hash: 387054d481e525e62148bced35aa7f1c5ac47981 |
Rules files suggestions |
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.
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:
The docker listener of the container plugin's go-worker only subscribed to the
create,startanddestroyevents. Whendocker compose uprecreates a container, docker creates it under a temporary<old-id[:12]>_<name>name and renames it before starting it. With the defaulthooks: ['create'], the container was inspected while it still had the temporary name and nothing updated it afterwards, socontainer.namestayed wrong until Falco restarted. A plaindocker renameof a running container was never picked up either, whatever the hooks.This PR always subscribes to the docker
renameevent and re-inspects the container like oncreate/start. The C++ side already overwrites the cached container on a new "added" event, so the cached name and the rest of the metadata get refreshed. If the inspection after a rename fails, nothing is sent, so the cached metadata is kept instead of being replaced with the minimum set.The rename subscription doesn't depend on the
hookssetting: a rename isn't a lifecycle hook, it changes metadata of a container that may already be cached whatever hook reported it. An alternative would be a new opt-inrenamehook value, but then the default config would stay broken for compose unless it became a default too. Happy to switch if maintainers prefer that.A new
TestDockerListenRenamereplays the compose sequence (create under the temporary name, then rename) against a fake Docker API that only sends the events matching the listener filters. It checks the final name with and without thecreatehook, and that a failed inspection on rename sends nothing.Which issue(s) this PR fixes:
Fixes #1601
Special notes for your reviewer:
starthook).renameevents; I can extendpodman.gothe same way here or in a follow-up if you want.🤖 Generated with Claude Code