From 2d6716ff1b338fbdeae2ccf83250aeb7d7e5c9ea Mon Sep 17 00:00:00 2001 From: Eric Shen Date: Wed, 4 Sep 2024 21:59:09 +0800 Subject: [PATCH] feat: add the operator resync duration var (#251) Signed-off-by: ericsyh --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 31e892f..1bdbf80 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ package main import ( "flag" "os" + "time" "github.com/streamnative/pulsar-resources-operator/pkg/feature" "github.com/streamnative/pulsar-resources-operator/pkg/utils" @@ -56,12 +57,14 @@ func main() { var metricsAddr string var enableLeaderElection bool var probeAddr string + var resyncPeriod int var retryCount int flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") + flag.IntVar(&resyncPeriod, "resync-period", 10, "resyncPeriod is the base frequency the informers are resynced.") flag.IntVar(&retryCount, "retry-count", 5, "The number of retries in case of error.") opts := k8szap.Options{} opts.BindFlags(flag.CommandLine) @@ -86,6 +89,8 @@ func main() { ctrl.SetLogger(k8szap.New(k8szap.UseFlagOptions(&opts), k8szap.Encoder(encoder))) + reSync := time.Duration(resyncPeriod) * time.Hour + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, MetricsBindAddress: metricsAddr, @@ -95,6 +100,7 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "feaa54b6.streamnative.io", + SyncPeriod: &reSync, }) if err != nil { setupLog.Error(err, "unable to start manager")