From 11cd2f50f0fcb6d4d5394af09e2f1fcaead120f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20T=C3=BCrken?= Date: Mon, 9 Sep 2024 18:57:36 +0300 Subject: [PATCH 1/2] Fix the issue of hiding errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fatih Türken --- pkg/controller/external_async_tfpluginfw.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/controller/external_async_tfpluginfw.go b/pkg/controller/external_async_tfpluginfw.go index 44845c67..4514c235 100644 --- a/pkg/controller/external_async_tfpluginfw.go +++ b/pkg/controller/external_async_tfpluginfw.go @@ -148,7 +148,6 @@ type panicHandler struct { // controller-runtime: // https://github.com/kubernetes-sigs/controller-runtime/blob/v0.17.3/pkg/internal/controller/controller.go#L105-L112 func (ph *panicHandler) recoverIfPanic() { - ph.err = nil if r := recover(); r != nil { for _, fn := range utilruntime.PanicHandlers { fn(r) From af44144929b08865b0d4df890557c5b6b630aa0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20T=C3=BCrken?= Date: Wed, 11 Sep 2024 12:50:23 +0300 Subject: [PATCH 2/2] Update recoverIfPanic() func comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fatih Türken --- pkg/controller/external_async_tfpluginfw.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/controller/external_async_tfpluginfw.go b/pkg/controller/external_async_tfpluginfw.go index 4514c235..1dc47336 100644 --- a/pkg/controller/external_async_tfpluginfw.go +++ b/pkg/controller/external_async_tfpluginfw.go @@ -139,13 +139,14 @@ type panicHandler struct { err error } -// recoverIfPanic recovers from panics, if any. Calls to this function -// should be defferred directly: `defer ph.recoverIfPanic()`. Panic -// recovery won't work if the call is wrapped in another function -// call, such as `defer func() { ph.recoverIfPanic() }()`. On -// recovery, API machinery panic handlers run. The implementation -// follows the outline of panic recovery mechanism in -// controller-runtime: +// recoverIfPanic recovers from panics, if any. Upon recovery, the +// error is set to a recovery message. Otherwise, the error is left +// unmodified. Calls to this function should be defferred directly: +// `defer ph.recoverIfPanic()`. Panic recovery won't work if the call +// is wrapped in another function call, such as `defer func() { +// ph.recoverIfPanic() }()`. On recovery, API machinery panic handlers +// run. The implementation follows the outline of panic recovery +// mechanism in controller-runtime: // https://github.com/kubernetes-sigs/controller-runtime/blob/v0.17.3/pkg/internal/controller/controller.go#L105-L112 func (ph *panicHandler) recoverIfPanic() { if r := recover(); r != nil {