Skip to content

Commit 7b8ccc0

Browse files
committed
Add pre-stop hook to print maps before exit
1 parent 56b8dab commit 7b8ccc0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/tracejob/job.go

+15
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,21 @@ func (t *TraceJobClient) CreateJob(nj TraceJob) (*batchv1.Job, error) {
296296
SecurityContext: &apiv1.SecurityContext{
297297
Privileged: boolPtr(true),
298298
},
299+
// We want to send SIGINT prior to the pod being killed, so we can print the map
300+
// we will also wait for an arbitrary amount of time (10s) to give bpftrace time to
301+
// process and summarize the data
302+
// FIXME should this sleep be configurable? 10s is probably ample for most cases.
303+
Lifecycle: &apiv1.Lifecycle{
304+
PreStop: &apiv1.Handler{
305+
Exec: &apiv1.ExecAction{
306+
Command: []string{
307+
"/bin/bash",
308+
"-c",
309+
"kill -SIGINT $(pidof bpftrace) && sleep 10",
310+
},
311+
},
312+
},
313+
},
299314
},
300315
},
301316
RestartPolicy: "Never",

0 commit comments

Comments
 (0)