Merge pull request #282 from huffmanca/issue276

Makes the number of worker threads configurable.
This commit is contained in:
Kubernetes Prow Robot
2020-03-31 11:59:00 -07:00
committed by GitHub
2 changed files with 4 additions and 10 deletions

View File

@@ -48,9 +48,6 @@ import (
)
const (
// Number of worker threads
threads = 10
// Default timeout of short CSI calls like GetPluginInfo
defaultCSITimeout = time.Minute
)
@@ -63,6 +60,7 @@ var (
snapshotNamePrefix = flag.String("snapshot-name-prefix", "snapshot", "Prefix to apply to the name of a created snapshot")
snapshotNameUUIDLength = flag.Int("snapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created snapshot. Defaults behavior is to NOT truncate.")
showVersion = flag.Bool("version", false, "Show version.")
threads = flag.Int("worker-threads", 10, "Number of worker threads.")
csiTimeout = flag.Duration("timeout", defaultCSITimeout, "The timeout for any RPCs to the CSI driver. Default is 1 minute.")
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
@@ -182,7 +180,7 @@ func main() {
stopCh := make(chan struct{})
factory.Start(stopCh)
coreFactory.Start(stopCh)
go ctrl.Run(threads, stopCh)
go ctrl.Run(*threads, stopCh)
// ...until SIGINT
c := make(chan os.Signal, 1)

View File

@@ -39,16 +39,12 @@ import (
coreinformers "k8s.io/client-go/informers"
)
const (
// Number of worker threads
threads = 10
)
// Command line flags
var (
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
resyncPeriod = flag.Duration("resync-period", 60*time.Second, "Resync interval of the controller.")
showVersion = flag.Bool("version", false, "Show version.")
threads = flag.Int("worker-threads", 10, "Number of worker threads.")
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
leaderElectionNamespace = flag.String("leader-election-namespace", "", "The namespace where the leader election resource exists. Defaults to the pod namespace if not set.")
@@ -111,7 +107,7 @@ func main() {
stopCh := make(chan struct{})
factory.Start(stopCh)
coreFactory.Start(stopCh)
go ctrl.Run(threads, stopCh)
go ctrl.Run(*threads, stopCh)
// ...until SIGINT
c := make(chan os.Signal, 1)