Skip to content

Commit

Permalink
Merge pull request #416 from pjbgf/panic-recovery
Browse files Browse the repository at this point in the history
Enable RecoverPanic
  • Loading branch information
Paulo Gomes authored Aug 10, 2022
2 parents 2d88b6f + 0fdcf7f commit 32944cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions controllers/imageupdateautomation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 32944cf

Please sign in to comment.