Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make resyncPeriod configurable #1013

Merged
merged 1 commit into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@johnugeorge johnugeorge May 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be the optimal default resync period? Currently, it is set to 30 sec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In k8s, the default resync period is 12 hour. tf-operator is event driven to reach the desired state, so we do not really need the resync mechanism. If the resync period is short, it may reduce the processing speed of tf-operator, so we can make it longer like k8s.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resync is strongly suggested by jeremy. But I think we do not really need it. 12h LGTM. If there are some problems caused by the long period, it should be somewhere has bugs in the implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. But since we are moving to v1, we need to test well to see if there are any hidden bugs.


// 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