Skip to content

Commit 3b2c0b6

Browse files
authored
Merge pull request #1781 from andyzhangx/add-driver-options
chore: set GoMaxProcs as 2
2 parents e02ba4d + f2816a6 commit 3b2c0b6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/blobplugin/main.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"net"
2424
"net/http"
2525
"os"
26+
"runtime"
2627
"strings"
2728

2829
"sigs.k8s.io/blob-csi-driver/pkg/blob"
@@ -45,9 +46,12 @@ var (
4546
allowEmptyCloudConfig = flag.Bool("allow-empty-cloud-config", true, "allow running driver without cloud config")
4647
kubeAPIQPS = flag.Float64("kube-api-qps", 25.0, "QPS to use while communicating with the kubernetes apiserver.")
4748
kubeAPIBurst = flag.Int("kube-api-burst", 50, "Burst to use while communicating with the kubernetes apiserver.")
49+
goMaxProcs = flag.Int("max-procs", 2, "maximum number of CPUs that can be executing simultaneously in golang runtime")
4850
)
4951

5052
func init() {
53+
klog.InitFlags(nil)
54+
_ = flag.Set("logtostderr", "true")
5155
driverOptions.AddFlags()
5256
}
5357

@@ -57,8 +61,6 @@ var exit = func(code int) {
5761
}
5862

5963
func main() {
60-
klog.InitFlags(nil)
61-
_ = flag.Set("logtostderr", "true")
6264
flag.Parse()
6365
if *version {
6466
info, err := blob.GetVersionYAML(driverOptions.DriverName)
@@ -74,6 +76,9 @@ func main() {
7476
}
7577

7678
func handle() {
79+
runtime.GOMAXPROCS(*goMaxProcs)
80+
klog.Infof("Sys info: NumCPU: %v MAXPROC: %v", runtime.NumCPU(), runtime.GOMAXPROCS(0))
81+
7782
userAgent := blob.GetUserAgent(driverOptions.DriverName, *customUserAgent, *userAgentSuffix)
7883
klog.V(2).Infof("driver userAgent: %s", userAgent)
7984

0 commit comments

Comments
 (0)