Skip to content
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

epbf: Propagate PID namespace to kernel space #3008

Merged
merged 6 commits into from
Feb 21, 2024

Conversation

simonswine
Copy link
Contributor

@simonswine simonswine commented Feb 15, 2024

If the ebpf profiler is running on another namespace than the host PID namespace, then the PIDs that are selected by Grafana Agent are not matching up with the ones collected.

This will respect the PID namespace the original process is running under.

Fixes #3002 #1994

Note this is based on #2996

@simonswine simonswine changed the title 20240215 support pid namespaces ebpf: aggregate python stacks in ebpf program instead of userspace Feb 15, 2024
@simonswine simonswine force-pushed the 20240215_support-pid-namespaces branch from 8aa1b23 to c206eb3 Compare February 15, 2024 17:40
@CLAassistant
Copy link

CLAassistant commented Feb 15, 2024

CLA assistant check
All committers have signed the CLA.

@simonswine simonswine force-pushed the 20240215_support-pid-namespaces branch from c206eb3 to 1222da9 Compare February 15, 2024 17:41
@simonswine simonswine changed the title ebpf: aggregate python stacks in ebpf program instead of userspace epbf: Propagate PID namespace to kernel space Feb 15, 2024
@simonswine simonswine force-pushed the 20240215_support-pid-namespaces branch from 2450007 to 7bccaa7 Compare February 19, 2024 11:51
@simonswine simonswine marked this pull request as ready for review February 19, 2024 11:51
Copy link
Collaborator

@korniltsev korniltsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM <3

If grafana-agent is running on another namespace than the host PID
namespace, then the PID that are selected by Grafana Agent are not
matching up with the ones collected.

This will respect the PID namespace the Grafana Agent is running under.

Fixes #3002 #1994
Replace use bpf_get_ns_current_pid_tgid, as it only matches in the exact
same namespace and not child namespaces.

This iterates up to 4 namespace levels up to find a match.
@simonswine simonswine force-pushed the 20240215_support-pid-namespaces branch from 7bccaa7 to 6a396d8 Compare February 19, 2024 12:15
ebpf/bpf/pid.h Outdated Show resolved Hide resolved
ebpf/python/perf.data Outdated Show resolved Hide resolved
@simonswine simonswine merged commit d58b751 into main Feb 21, 2024
19 checks passed
@simonswine simonswine deleted the 20240215_support-pid-namespaces branch February 21, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eBPF: Matching of PID fails in nested namespace deployment
3 participants