From d6ef7bda79975984a7492993c13b00b03a5ce254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20T=C3=BCrken?= Date: Mon, 25 Sep 2023 18:33:20 +0300 Subject: [PATCH 1/2] Add jitter to reconcile delay for managed.Reconciler --- pkg/controller/options.go | 4 ++++ pkg/pipeline/templates/controller.go.tmpl | 1 + 2 files changed, 5 insertions(+) diff --git a/pkg/controller/options.go b/pkg/controller/options.go index ae265f4c..f660fe1f 100644 --- a/pkg/controller/options.go +++ b/pkg/controller/options.go @@ -6,6 +6,7 @@ package controller import ( "crypto/tls" + "time" "github.com/crossplane/crossplane-runtime/pkg/controller" "k8s.io/apimachinery/pkg/runtime/schema" @@ -38,6 +39,9 @@ type Options struct { // ESSOptions for External Secret Stores. ESSOptions *ESSOptions + + // Adds jitter to reconcile latency for managed.Reconciler. + PollJitter time.Duration } // ESSOptions for External Secret Stores. diff --git a/pkg/pipeline/templates/controller.go.tmpl b/pkg/pipeline/templates/controller.go.tmpl index 18d39219..23d95063 100644 --- a/pkg/pipeline/templates/controller.go.tmpl +++ b/pkg/pipeline/templates/controller.go.tmpl @@ -53,6 +53,7 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), + managed.WithPollJitterHook(o.PollJitter), } {{- if .FeaturesPackageAlias }} if o.Features.Enabled({{ .FeaturesPackageAlias }}EnableAlphaManagementPolicies) { From e283b5ce390335507970dfac73777706bb5209a5 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 27 Sep 2023 21:47:09 +0300 Subject: [PATCH 2/2] Only configure poll jitter if the jitter is non-zero Signed-off-by: Alper Rifat Ulucinar --- pkg/controller/options.go | 3 ++- pkg/pipeline/templates/controller.go.tmpl | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/controller/options.go b/pkg/controller/options.go index f660fe1f..32e091fb 100644 --- a/pkg/controller/options.go +++ b/pkg/controller/options.go @@ -40,7 +40,8 @@ type Options struct { // ESSOptions for External Secret Stores. ESSOptions *ESSOptions - // Adds jitter to reconcile latency for managed.Reconciler. + // PollJitter adds the specified jitter to the configured reconcile period + // of the up-to-date resources in managed.Reconciler. PollJitter time.Duration } diff --git a/pkg/pipeline/templates/controller.go.tmpl b/pkg/pipeline/templates/controller.go.tmpl index 23d95063..4dcb6d8f 100644 --- a/pkg/pipeline/templates/controller.go.tmpl +++ b/pkg/pipeline/templates/controller.go.tmpl @@ -53,7 +53,9 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { managed.WithInitializers(initializers), managed.WithConnectionPublishers(cps...), managed.WithPollInterval(o.PollInterval), - managed.WithPollJitterHook(o.PollJitter), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) } {{- if .FeaturesPackageAlias }} if o.Features.Enabled({{ .FeaturesPackageAlias }}EnableAlphaManagementPolicies) {