Skip to content

Commit

Permalink
Add pre-stop hook to print maps before exit
Browse files Browse the repository at this point in the history
  • Loading branch information
dalehamel committed Sep 16, 2019
1 parent 56b8dab commit 7b8ccc0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/tracejob/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7b8ccc0

Please sign in to comment.