Skip to content

Commit 854beb2

Browse files
committed
add ctx to PanicHandlers
1 parent bc065d6 commit 854beb2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pkg/controller/controllercmd/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func (b *ControllerBuilder) Run(ctx context.Context, config *unstructured.Unstru
268268
}
269269
eventRecorder := events.NewKubeRecorderWithOptions(kubeClient.CoreV1().Events(namespace), b.eventRecorderOptions, b.componentName, controllerRef)
270270

271-
utilruntime.PanicHandlers = append(utilruntime.PanicHandlers, func(r interface{}) {
271+
utilruntime.PanicHandlers = append(utilruntime.PanicHandlers, func(c context.Context, r interface{}) {
272272
eventRecorder.Warningf(fmt.Sprintf("%sPanic", strings.Title(b.componentName)), "Panic observed: %v", r)
273273
})
274274

pkg/serviceability/panic.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package serviceability
22

33
import (
4+
"context"
45
"encoding/json"
56
"strings"
67
"time"
@@ -65,8 +66,8 @@ func behaviorOnPanic(mode string, productVersion version.Info) func() {
6566
}
6667
}
6768

68-
func crashOnDelay(delay time.Duration, delayString string) func(interface{}) {
69-
return func(in interface{}) {
69+
func crashOnDelay(delay time.Duration, delayString string) func(context.Context, interface{}) {
70+
return func(ctx context.Context, in interface{}) {
7071
go func() {
7172
klog.Errorf("Panic happened. Process will crash in %v.", delayString)
7273
time.Sleep(delay)

0 commit comments

Comments
 (0)