mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 20:00:07 +00:00
feat: use contextual HandleCrash when possible
This commit is contained in:
@@ -767,7 +767,7 @@ func (m *kubeGenericRuntimeManager) executePreStopHook(ctx context.Context, pod
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
if _, err := m.runner.Run(ctx, containerID, pod, containerSpec, containerSpec.Lifecycle.PreStop); err != nil {
|
||||
logger.Error(err, "PreStop hook failed", "pod", klog.KObj(pod), "podUID", pod.UID,
|
||||
"containerName", containerSpec.Name, "containerID", containerID.String())
|
||||
@@ -923,7 +923,7 @@ func (m *kubeGenericRuntimeManager) killContainersWithSyncResult(ctx context.Con
|
||||
}
|
||||
for _, container := range runningPod.Containers {
|
||||
go func(container *kubecontainer.Container) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer wg.Done()
|
||||
|
||||
killContainerResult := kubecontainer.NewSyncResult(kubecontainer.KillContainer, container.Name)
|
||||
|
||||
@@ -78,7 +78,7 @@ func (ow *realWatcher) Start(ctx context.Context, ref *v1.ObjectReference) error
|
||||
|
||||
go func() {
|
||||
logger := klog.FromContext(ctx)
|
||||
defer runtime.HandleCrash()
|
||||
defer runtime.HandleCrashWithContext(ctx)
|
||||
|
||||
for event := range outStream {
|
||||
if event.VictimContainerName == recordEventContainerName {
|
||||
|
||||
@@ -107,7 +107,7 @@ type pluginManager struct {
|
||||
var _ PluginManager = &pluginManager{}
|
||||
|
||||
func (pm *pluginManager) Run(ctx context.Context, sourcesReady config.SourcesReady, stopCh <-chan struct{}) {
|
||||
defer runtime.HandleCrash()
|
||||
defer runtime.HandleCrashWithContext(ctx)
|
||||
|
||||
logger := klog.FromContext(ctx)
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ func (w *worker) stop() {
|
||||
// Returns whether the worker should continue.
|
||||
func (w *worker) doProbe(ctx context.Context) (keepGoing bool) {
|
||||
defer func() { recover() }() // Actually eat panics (HandleCrash takes care of logging)
|
||||
defer runtime.HandleCrash(func(_ interface{}) { keepGoing = true })
|
||||
defer runtime.HandleCrashWithContext(ctx, func(ctx context.Context, _ interface{}) { keepGoing = true })
|
||||
|
||||
logger := klog.FromContext(ctx)
|
||||
startTime := time.Now()
|
||||
|
||||
@@ -298,7 +298,7 @@ func (e *VolumeAttachLimitExceededError) Error() string {
|
||||
|
||||
func (vm *volumeManager) Run(ctx context.Context, sourcesReady config.SourcesReady) {
|
||||
logger := klog.FromContext(ctx)
|
||||
defer runtime.HandleCrash()
|
||||
defer runtime.HandleCrashWithContext(ctx)
|
||||
|
||||
if vm.kubeClient != nil {
|
||||
// start informer for CSIDriver
|
||||
|
||||
Reference in New Issue
Block a user