File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ const (
3939 KubernetesInternalDomainEnvVar = "MESSAGING_DOMAIN_NAME"
4040 OperatorNamespaceEnvVar = "OPERATOR_NAMESPACE"
4141 EnableWebhooksEnvVar = "ENABLE_WEBHOOKS"
42+ ControllerSyncPeriodEnvVar = "SYNC_PERIOD"
4243)
4344
4445type TopologyController interface {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import (
1616 "os"
1717 "regexp"
1818 "strings"
19+ "time"
1920
2021 "k8s.io/apimachinery/pkg/runtime"
2122 clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -87,13 +88,25 @@ func main() {
8788
8889 clusterDomain := sanitizeClusterDomainInput (os .Getenv (controllers .KubernetesInternalDomainEnvVar ))
8990
90- mgr , err := ctrl . NewManager ( ctrl . GetConfigOrDie (), ctrl.Options {
91+ managerOpts := ctrl.Options {
9192 Scheme : scheme ,
9293 MetricsBindAddress : metricsAddr ,
9394 LeaderElection : true ,
9495 LeaderElectionNamespace : operatorNamespace ,
9596 LeaderElectionID : "messaging-topology-operator-leader-election" ,
96- })
97+ }
98+
99+ if syncPeriod := os .Getenv (controllers .ControllerSyncPeriodEnvVar ); syncPeriod != "" {
100+ syncPeriodDuration , err := time .ParseDuration (syncPeriod )
101+ if err != nil {
102+ log .Error (err , "unable to parse provided sync period" , "sync period" , syncPeriod )
103+ os .Exit (1 )
104+ }
105+ managerOpts .SyncPeriod = & syncPeriodDuration
106+ log .Info (fmt .Sprintf ("sync period set; all resources will be reconciled every: %s" , syncPeriodDuration ))
107+ }
108+
109+ mgr , err := ctrl .NewManager (ctrl .GetConfigOrDie (), managerOpts )
97110 if err != nil {
98111 log .Error (err , "unable to start manager" )
99112 os .Exit (1 )
You can’t perform that action at this time.
0 commit comments