From 599f4832be982abded24e2a19e34de70d4341488 Mon Sep 17 00:00:00 2001 From: Johnu George Date: Mon, 3 Jun 2019 13:41:52 +0530 Subject: [PATCH] Making ResyncPeriod configurable --- cmd/pytorch-operator.v1/app/options/options.go | 7 +++++++ cmd/pytorch-operator.v1/app/server.go | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/pytorch-operator.v1/app/options/options.go b/cmd/pytorch-operator.v1/app/options/options.go index 2a5cceb7b..1c4c54884 100644 --- a/cmd/pytorch-operator.v1/app/options/options.go +++ b/cmd/pytorch-operator.v1/app/options/options.go @@ -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 @@ -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. @@ -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") } diff --git a/cmd/pytorch-operator.v1/app/server.go b/cmd/pytorch-operator.v1/app/server.go index ec13b60f9..ef233a7d5 100644 --- a/cmd/pytorch-operator.v1/app/server.go +++ b/cmd/pytorch-operator.v1/app/server.go @@ -52,7 +52,6 @@ var ( leaseDuration = 15 * time.Second renewDuration = 5 * time.Second retryPeriod = 3 * time.Second - resyncPeriod = 30 * time.Second ) const RecommendedKubeConfigPathEnv = "KUBECONFIG" @@ -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)