Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Making ResyncPeriod configurable #169

Merged
merged 1 commit into from
Jun 3, 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
7 changes: 7 additions & 0 deletions cmd/pytorch-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 @@ -54,5 +58,8 @@ 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/pytorch-operator.v1/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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 @@ -98,8 +97,8 @@ func Run(opt *options.ServerOption) error {
os.Exit(1)
}
// Create informer factory.
kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(kubeClientSet, resyncPeriod, opt.Namespace, nil)
pytorchJobInformerFactory := jobinformers.NewSharedInformerFactory(pytorchJobClientSet, resyncPeriod)
kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(kubeClientSet, opt.ResyncPeriod, opt.Namespace, nil)
pytorchJobInformerFactory := jobinformers.NewSharedInformerFactory(pytorchJobClientSet, opt.ResyncPeriod)

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

Expand Down