From 205c22ddbec918542a24881d106acefc7de9ba2a Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Thu, 18 Mar 2021 10:28:16 -0400 Subject: [PATCH] impersonator config: catch panics when running impersonator Signed-off-by: Monis Khan --- internal/controller/impersonatorconfig/impersonator_config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/controller/impersonatorconfig/impersonator_config.go b/internal/controller/impersonatorconfig/impersonator_config.go index 4fc140d8..72cd4d68 100644 --- a/internal/controller/impersonatorconfig/impersonator_config.go +++ b/internal/controller/impersonatorconfig/impersonator_config.go @@ -20,6 +20,7 @@ import ( "k8s.io/apimachinery/pkg/util/clock" "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/intstr" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/sets" corev1informers "k8s.io/client-go/informers/core/v1" "k8s.io/client-go/kubernetes" @@ -383,6 +384,8 @@ func (c *impersonatorConfigController) ensureImpersonatorIsStarted(syncCtx contr // startImpersonatorFunc will block until the server shuts down (or fails to start), so run it in the background. go func() { + defer utilruntime.HandleCrash() + // The server has stopped, so enqueue ourselves for another sync, // so we can try to start the server again as quickly as possible. defer syncCtx.Queue.AddRateLimited(syncCtx.Key)