Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions enterprise/cmd/exectrace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package main

import (
"fmt"
"os"
"strings"
"time"
Expand All @@ -20,6 +21,8 @@ func main() {

err := app.Run(os.Args)
if err != nil {
// Without this the process exits with no indication of why.
fmt.Fprintf(os.Stderr, "exectrace: %v\n", err)
os.Exit(1)
}
}
Expand Down
22 changes: 12 additions & 10 deletions enterprise/exectrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ import (
)

const (
debugFS = "debugfs"
debugFSMountpoint = "/sys/kernel/debug"
traceFS = "tracefs"
traceFSMountpoint = debugFSMountpoint + "/tracing"
traceFS = "tracefs"
// traceFSMountpoint is the canonical tracefs location (since Linux 4.1).
//
// We intentionally don't use /sys/kernel/debug/tracing: that path only
// exists when the kernel automounts tracefs inside debugfs
// (CONFIG_TRACEFS_AUTOMOUNT_DEPRECATED, deprecated since Linux 6.17).
// Kernels built without it, such as Talos Linux 1.14, have no "tracing"
// directory in debugfs and debugfs doesn't allow creating one, so mounting
// there fails.
traceFSMountpoint = "/sys/kernel/tracing"
)

type Options struct {
Expand Down Expand Up @@ -59,13 +65,9 @@ func Run(ctx context.Context, log slog.Logger, opts Options) error {
}
log.Debug(ctx, "got PidNS", slog.F("pid_ns", pidNS))

// We need to make sure that debugfs is mounted at /sys/kernel/debug and
// tracefs is mounted at /sys/kernel/debug/tracing.
// We need to make sure that tracefs is mounted at /sys/kernel/tracing so
// the tracepoint can be attached.
log.Debug(ctx, "preparing environment for eBPF tracing")
err = ensureVirtualMountpoint(debugFS, debugFSMountpoint, nil)
if err != nil {
return xerrors.Errorf("ensure debugfs mounted: %w", err)
}
err = ensureVirtualMountpoint(traceFS, traceFSMountpoint, nil)
if err != nil {
return xerrors.Errorf("ensure tracefs mounted: %w", err)
Expand Down
Loading