Enable RecoverPanic

The controller-runtime provides the ability to recover from
panics that have arisen from a reconciliation. This change
enables this functionality by default.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
Paulo Gomes 2022-08-10 09:59:19 +01:00
parent 2d88b6f3ff
commit 0fdcf7fe6d
No known key found for this signature in database
GPG Key ID: 9995233870E99BEE
2 changed files with 9 additions and 1 deletions

View File

@ -96,6 +96,7 @@ type ImageUpdateAutomationReconciler struct {
type ImageUpdateAutomationReconcilerOptions struct {
MaxConcurrentReconciles int
RateLimiter ratelimiter.RateLimiter
RecoverPanic bool
}
// +kubebuilder:rbac:groups=image.toolkit.fluxcd.io,resources=imageupdateautomations,verbs=get;list;watch;create;update;patch;delete
@ -443,6 +444,7 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(mgr ctrl.Manager, opt
WithOptions(controller.Options{
MaxConcurrentReconciles: opts.MaxConcurrentReconciles,
RateLimiter: opts.RateLimiter,
RecoverPanic: opts.RecoverPanic,
}).
Complete(r)
}

View File

@ -50,7 +50,12 @@ import (
"github.com/fluxcd/image-automation-controller/controllers"
)
const controllerName = "image-automation-controller"
const (
controllerName = "image-automation-controller"
// recoverPanic indicates whether panic caused by reconciles should be recovered.
recoverPanic = true
)
var (
scheme = runtime.NewScheme()
@ -155,6 +160,7 @@ func main() {
}).SetupWithManager(mgr, controllers.ImageUpdateAutomationReconcilerOptions{
MaxConcurrentReconciles: concurrent,
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
RecoverPanic: recoverPanic,
}); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ImageUpdateAutomation")
os.Exit(1)