-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(process-monitor): Detect new containers #213
Conversation
bc49800
to
b43c665
Compare
ae25f67
to
96e41d7
Compare
11e1aab
to
407ce85
Compare
b952273
to
64a4ec9
Compare
Enhance the process monitor with an ability to detect when a container runtime creates a new PID namespace, which we can consider as a creation of a new container. Achieve that by: * Registering the inodes of container runtime binaries we want to track in the user-space, saving them in a BPF map. * In BPF, every time a process is being executed using the runtime binary, checking whether the PID namespace was changed.
PID namespace can be omitted by passing `--pid=host` to Docker or podman. Checking mount namespace is more reliable.
* Don't show namespaces and `is_new_container` bool. * Show container info, but only if a process is containerized.
crates/pulsar-core/src/event.rs
Outdated
#[validatron(skip)] | ||
container: Option<ContainerInfo>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be removed from here as it already present in the header. same thing for the fork event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove it there, I won't be able to use it here belowi, in the impl Format for Payload
block:
There is no access to the header in this place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I can remove is_new_container
, it's not needed in payloads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I removed all namespace and container-related stuff from payloads, it's only in header now. And container details are getting formatted from header now.
crates/pulsar-core/src/event.rs
Outdated
@@ -196,12 +199,18 @@ pub enum Payload { | |||
Fork { | |||
ppid: i32, | |||
namespaces: Namespaces, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably Namespaces
should be included in the header via process_tracker and here should be a skip(validatron)
. in this way the only reason of having it in the fork event is an optimization to avoid multiple readings from /proc
. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing for exec event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Enhance the process monitor with an ability to detect when a
container runtime creates a new mount namespace, which we can consider
as a creation of a new container.
Achieve that by:
track in the user-space, saving them in a BPF map.
binary, checking whether the PID namespace was changed.