diff --git a/pkg/tracejob/job.go b/pkg/tracejob/job.go index a3ded20d..01a1950e 100644 --- a/pkg/tracejob/job.go +++ b/pkg/tracejob/job.go @@ -296,6 +296,21 @@ func (t *TraceJobClient) CreateJob(nj TraceJob) (*batchv1.Job, error) { SecurityContext: &apiv1.SecurityContext{ Privileged: boolPtr(true), }, + // We want to send SIGINT prior to the pod being killed, so we can print the map + // we will also wait for an arbitrary amount of time (10s) to give bpftrace time to + // process and summarize the data + // FIXME should this sleep be configurable? 10s is probably ample for most cases. + Lifecycle: &apiv1.Lifecycle{ + PreStop: &apiv1.Handler{ + Exec: &apiv1.ExecAction{ + Command: []string{ + "/bin/bash", + "-c", + "kill -SIGINT $(pidof bpftrace) && sleep 10", + }, + }, + }, + }, }, }, RestartPolicy: "Never",