Skip to content

Commit 69db084

Browse files
authored
Merge pull request #282 from huffmanca/issue276
Makes the number of worker threads configurable.
2 parents 505542b + 12f4e1c commit 69db084

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

cmd/csi-snapshotter/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ import (
4848
)
4949

5050
const (
51-
// Number of worker threads
52-
threads = 10
53-
5451
// Default timeout of short CSI calls like GetPluginInfo
5552
defaultCSITimeout = time.Minute
5653
)
@@ -63,6 +60,7 @@ var (
6360
snapshotNamePrefix = flag.String("snapshot-name-prefix", "snapshot", "Prefix to apply to the name of a created snapshot")
6461
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.")
6562
showVersion = flag.Bool("version", false, "Show version.")
63+
threads = flag.Int("worker-threads", 10, "Number of worker threads.")
6664
csiTimeout = flag.Duration("timeout", defaultCSITimeout, "The timeout for any RPCs to the CSI driver. Default is 1 minute.")
6765

6866
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
@@ -182,7 +180,7 @@ func main() {
182180
stopCh := make(chan struct{})
183181
factory.Start(stopCh)
184182
coreFactory.Start(stopCh)
185-
go ctrl.Run(threads, stopCh)
183+
go ctrl.Run(*threads, stopCh)
186184

187185
// ...until SIGINT
188186
c := make(chan os.Signal, 1)

cmd/snapshot-controller/main.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,12 @@ import (
3939
coreinformers "k8s.io/client-go/informers"
4040
)
4141

42-
const (
43-
// Number of worker threads
44-
threads = 10
45-
)
46-
4742
// Command line flags
4843
var (
4944
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
5045
resyncPeriod = flag.Duration("resync-period", 60*time.Second, "Resync interval of the controller.")
5146
showVersion = flag.Bool("version", false, "Show version.")
47+
threads = flag.Int("worker-threads", 10, "Number of worker threads.")
5248

5349
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
5450
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() {
111107
stopCh := make(chan struct{})
112108
factory.Start(stopCh)
113109
coreFactory.Start(stopCh)
114-
go ctrl.Run(threads, stopCh)
110+
go ctrl.Run(*threads, stopCh)
115111

116112
// ...until SIGINT
117113
c := make(chan os.Signal, 1)

0 commit comments

Comments
 (0)