Skip to content

Commit d97b421

Browse files
authored
Merge pull request #158 from parca-dev/container_fix
Fix usdt attachment to containers
2 parents a1c6489 + b5091d0 commit d97b421

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

interpreter/gpu/cuda.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func validateProbeArguments(probes []pfelf.USDTProbe, path string) error {
101101
}
102102

103103
func (d *data) Attach(ebpf interpreter.EbpfHandler, pid libpf.PID, _ libpf.Address,
104-
_ remotememory.RemoteMemory) (ii interpreter.Instance, err error) {
104+
_ remotememory.RemoteMemory) (interpreter.Instance, error) {
105105
// Maps usdt probe name to ebpf program name.
106106
// Use the first character of the probe name as a cookie.
107107
// 'c' -> cuda_correlation

processmanager/ebpf/ebpf.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,15 @@ func (lc *linkCloser) Unload() error {
166166
func (impl *ebpfMapsImpl) AttachUSDTProbes(pid libpf.PID, path, multiProgName string,
167167
probes []pfelf.USDTProbe, cookies []uint64, singleProgNames []string,
168168
probeAll bool) (interpreter.LinkCloser, error) {
169-
exe, err := link.OpenExecutable(path)
169+
containerPath := fmt.Sprintf("/proc/%d/root/%s", pid, path)
170+
171+
// TODO: This will crack open the exe with debug.elf and read symbols, we should
172+
// contribute a PR to cilium to allow it to delegate to pfelf instead. This will
173+
// also allow us to avoid the proc/pid/root stuff.
174+
exe, err := link.OpenExecutable(containerPath)
170175
if err != nil {
176+
// The upstack code will swallow file not found errors so drop a crumb.
177+
log.Warnf("failed to open executable in AttachUSDTProbes %v", err)
171178
return nil, err
172179
}
173180

0 commit comments

Comments
 (0)