Skip to content

Commit

Permalink
feat: add the operator resync duration var (#251)
Browse files Browse the repository at this point in the history
Signed-off-by: ericsyh <[email protected]>
  • Loading branch information
ericsyh authored Sep 4, 2024
1 parent 9cb8814 commit 2d6716f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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")
Expand Down

0 comments on commit 2d6716f

Please sign in to comment.