Problem
In main.go:173, the signal handler calls os.Exit(0) which bypasses all deferred cleanup functions:
registry.Close() — never called
tracer.Close() — eBPF programs, uprobes, perf buffers, ring buffers leak
profiling.Stop() — never called
On every pod restart/rollout, kernel resources (eBPF maps, programs, uprobes) are leaked. On a daemonset that restarts frequently, this compounds.
Fix
Replace os.Exit(0) with context cancellation. Propagate context.Context through the main function and let deferred cleanup run naturally.
ctx, cancel := context.WithCancel(context.Background())
go func() {
sigChannel := make(chan os.Signal, 1)
signal.Notify(sigChannel, os.Interrupt, syscall.SIGTERM)
<-sigChannel
klog.Infoln("Received signal, shutting down")
cancel()
}()
// ... use ctx in main loop ...
// deferred Close() calls will run on natural exit
Impact
High — kernel resource leaks on every restart.
Problem
In
main.go:173, the signal handler callsos.Exit(0)which bypasses all deferred cleanup functions:registry.Close()— never calledtracer.Close()— eBPF programs, uprobes, perf buffers, ring buffers leakprofiling.Stop()— never calledOn every pod restart/rollout, kernel resources (eBPF maps, programs, uprobes) are leaked. On a daemonset that restarts frequently, this compounds.
Fix
Replace
os.Exit(0)with context cancellation. Propagatecontext.Contextthrough the main function and let deferred cleanup run naturally.Impact
High — kernel resource leaks on every restart.