Skip to content

Commit

Permalink
Add option to customize controller sync interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Saremox committed May 8, 2024
1 parent 6b3fefc commit dc2ec5e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type CMDFlags struct {
K8sQueriesPerSecond int
K8sQueriesBurstable int
Concurrency int
SyncInterval int
LogLevel string
}

Expand All @@ -38,6 +39,7 @@ func (c *CMDFlags) Init() {
// default is 3 for conccurency because kooper also defines 3 as default
// reference: https://github.com/spotahome/kooper/blob/master/controller/controller.go#L89
flag.IntVar(&c.Concurrency, "concurrency", 3, "Number of conccurent workers meant to process events")
flag.IntVar(&c.SyncInterval, "sync-interval", 30, "Number of seconds between checks")
flag.StringVar(&c.LogLevel, "log-level", "info", "set log level")
// Parse flags
flag.Parse()
Expand All @@ -53,6 +55,7 @@ func (c *CMDFlags) ToRedisOperatorConfig() redisfailover.Config {
ListenAddress: c.ListenAddr,
MetricsPath: c.MetricsPath,
Concurrency: c.Concurrency,
SyncInterval: c.SyncInterval,
SupportedNamespacesRegex: c.SupportedNamespacesRegex,
}
}
1 change: 1 addition & 0 deletions operator/redisfailover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ type Config struct {
ListenAddress string
MetricsPath string
Concurrency int
SyncInterval int
SupportedNamespacesRegex string
}
3 changes: 1 addition & 2 deletions operator/redisfailover/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
)

const (
resync = 30 * time.Second
operatorName = "redis-operator"
lockKey = "redis-failover-lease"
)
Expand Down Expand Up @@ -55,7 +54,7 @@ func New(cfg Config, k8sService k8s.Services, k8sClient kubernetes.Interface, lo
MetricsRecorder: kooperMetricsRecorder,
Logger: kooperLogger,
Name: "redisfailover",
ResyncInterval: resync,
ResyncInterval: time.Duration(cfg.SyncInterval) * time.Second,
ConcurrentWorkers: cfg.Concurrency,
})
}
Expand Down

0 comments on commit dc2ec5e

Please sign in to comment.