From 1ad2f004ac380102717cc6a4f3603bca250081ad Mon Sep 17 00:00:00 2001 From: Santosh Kaluskar Date: Tue, 9 Aug 2022 19:33:15 +0530 Subject: [PATCH] Implementing RecoverPanic on reconcilers to ensure it recovers from panic instead of crashing the controller and Squashed commits. Signed-off-by: Santosh Kaluskar --- controllers/bucket_controller.go | 1 + controllers/gitrepository_controller.go | 1 + controllers/helmchart_controller.go | 1 + controllers/helmrepository_controller.go | 1 + controllers/helmrepository_controller_oci.go | 1 + controllers/ocirepository_controller.go | 1 + 6 files changed, 6 insertions(+) diff --git a/controllers/bucket_controller.go b/controllers/bucket_controller.go index eaff174c4..b5545049c 100644 --- a/controllers/bucket_controller.go +++ b/controllers/bucket_controller.go @@ -241,6 +241,7 @@ func (r *BucketReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts Buc WithOptions(controller.Options{ MaxConcurrentReconciles: opts.MaxConcurrentReconciles, RateLimiter: opts.RateLimiter, + RecoverPanic: true, }). Complete(r) } diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index 3cfb26198..64f651efa 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -156,6 +156,7 @@ func (r *GitRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, o WithOptions(controller.Options{ MaxConcurrentReconciles: opts.MaxConcurrentReconciles, RateLimiter: opts.RateLimiter, + RecoverPanic: true, }). Complete(r) } diff --git a/controllers/helmchart_controller.go b/controllers/helmchart_controller.go index a3bd7d6a8..032f678bb 100644 --- a/controllers/helmchart_controller.go +++ b/controllers/helmchart_controller.go @@ -176,6 +176,7 @@ func (r *HelmChartReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, opts WithOptions(controller.Options{ MaxConcurrentReconciles: opts.MaxConcurrentReconciles, RateLimiter: opts.RateLimiter, + RecoverPanic: true, }). Complete(r) } diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go index 14bdbb240..11fdf1af7 100644 --- a/controllers/helmrepository_controller.go +++ b/controllers/helmrepository_controller.go @@ -142,6 +142,7 @@ func (r *HelmRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, WithOptions(controller.Options{ MaxConcurrentReconciles: opts.MaxConcurrentReconciles, RateLimiter: opts.RateLimiter, + RecoverPanic: true, }). Complete(r) } diff --git a/controllers/helmrepository_controller_oci.go b/controllers/helmrepository_controller_oci.go index 70af64e04..a7d812fa0 100644 --- a/controllers/helmrepository_controller_oci.go +++ b/controllers/helmrepository_controller_oci.go @@ -102,6 +102,7 @@ func (r *HelmRepositoryOCIReconciler) SetupWithManagerAndOptions(mgr ctrl.Manage WithOptions(controller.Options{ MaxConcurrentReconciles: opts.MaxConcurrentReconciles, RateLimiter: opts.RateLimiter, + RecoverPanic: true, }). Complete(r) } diff --git a/controllers/ocirepository_controller.go b/controllers/ocirepository_controller.go index f9e408ed3..2a4993bbb 100644 --- a/controllers/ocirepository_controller.go +++ b/controllers/ocirepository_controller.go @@ -147,6 +147,7 @@ func (r *OCIRepositoryReconciler) SetupWithManagerAndOptions(mgr ctrl.Manager, o WithOptions(controller.Options{ MaxConcurrentReconciles: opts.MaxConcurrentReconciles, RateLimiter: opts.RateLimiter, + RecoverPanic: true, }). Complete(r) }