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

WIP fixing profiling nginx in a container #4

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dalehamel
Copy link

@dalehamel dalehamel commented Feb 9, 2023

This is a draft, not ready for review yet.

I was attempting to use this tool to profile an nginx instance running in a container, but many of the ELF helpers don't understand how to deal with containerized paths.

The fix for this is relatively simple, we just prepend /proc/PID/root to the paths, to make them relative to the target pid's mount namespace.

Since the helpers don't take a pid, for now I've hacked it by adding a static variable and storing this early on when we are looking for the lib / binary to profile.

After these changes, I am able to profile an nginx instance running in a container, provided I have access to the root pid namespace.

I also discovered an issue with the makefile, which I will PR separately but is currently included in this branch.

  • Look into cleaner way to obtain the PID than storing in a static variable
  • Create mount namespace helpers rather than duplicating the code
  • Tests?
  • Whitespace fixes / formatting
  • Create separate PR for makefile fix

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.

1 participant