Skip to content

Commit

Permalink
make resyncPeriod Configurable (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
wackxu authored and k8s-ci-robot committed May 29, 2019
1 parent 61f9ea6 commit 2f0d959
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cmd/tf-operator.v1/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ package options

import (
"flag"
"time"

"k8s.io/api/core/v1"
)

const DefaultResyncPeriod = 12 * time.Hour

// ServerOption is the main context object for the controller manager.
type ServerOption struct {
Kubeconfig string
Expand All @@ -29,6 +32,7 @@ type ServerOption struct {
JSONLogFormat bool
EnableGangScheduling bool
Namespace string
ResyncPeriod time.Duration
}

// NewServerOption creates a new CMServer with a default config.
Expand All @@ -55,4 +59,6 @@ func (s *ServerOption) AddFlags(fs *flag.FlagSet) {
fs.BoolVar(&s.JSONLogFormat, "json-log-format", true,
"Set true to use json style log format. Set false to use plaintext style log format")
fs.BoolVar(&s.EnableGangScheduling, "enable-gang-scheduling", false, "Set true to enable gang scheduling by kube-batch.")

fs.DurationVar(&s.ResyncPeriod, "resyc-period", DefaultResyncPeriod, "Resync interval of the tf-operator")
}
5 changes: 2 additions & 3 deletions cmd/tf-operator.v1/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var (
leaseDuration = 15 * time.Second
renewDuration = 5 * time.Second
retryPeriod = 3 * time.Second
resyncPeriod = 30 * time.Second
)

const RecommendedKubeConfigPathEnv = "KUBECONFIG"
Expand Down Expand Up @@ -101,8 +100,8 @@ func Run(opt *options.ServerOption) error {
os.Exit(1)
}
// Create informer factory.
kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(kubeClientSet, resyncPeriod, opt.Namespace, nil)
tfJobInformerFactory := tfjobinformers.NewSharedInformerFactory(tfJobClientSet, resyncPeriod)
kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(kubeClientSet, opt.ResyncPeriod, opt.Namespace, nil)
tfJobInformerFactory := tfjobinformers.NewSharedInformerFactory(tfJobClientSet, opt.ResyncPeriod)

unstructuredInformer := controller.NewUnstructuredTFJobInformer(kcfg, opt.Namespace)

Expand Down

0 comments on commit 2f0d959

Please sign in to comment.