Skip to content

Commit 7e30553

Browse files
authored
Merge pull request #1304 from nixpanic/automaxprocs
Add `-automaxprocs` flag for configuring `GOMAXPROCS`
2 parents 4cedb3f + d6349a2 commit 7e30553

File tree

21 files changed

+1208
-24
lines changed

21 files changed

+1208
-24
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ Specifically, `deploy/kubernetes/snapshot-controller/setup-snapshot-controller.y
166166

167167
* `--resync-period <duration>`: Internal resync interval when the snapshot controller re-evaluates all existing `VolumeSnapshot` instances and tries to fulfill them, i.e. create / delete corresponding snapshots. It does not affect re-tries of failed calls! It should be used only when there is a bug in Kubernetes watch logic. Default is 15 minutes.
168168

169+
* `--automaxprocs`: Automatically set the `GOMAXPROCS` environment variable to match the configured Linux container CPU quota. Defaults to false.
170+
169171
* `--version`: Prints current snapshot controller version and quits.
170172

171173
* All glog / klog arguments are supported, such as `-v <log level>` or `-alsologtostderr`.
@@ -212,6 +214,8 @@ Specifically, `deploy/kubernetes/snapshot-controller/setup-snapshot-controller.y
212214

213215
* `--resync-period <duration>`: Internal resync interval when the CSI external-snapshotter re-evaluates all existing `VolumeSnapshotContent` instances and tries to fulfill them, i.e. update / delete corresponding snapshots. It does not affect re-tries of failed CSI calls! It should be used only when there is a bug in Kubernetes watch logic. Default is 15 minutes.
214216

217+
* `--automaxprocs`: Automatically set the `GOMAXPROCS` environment variable to match the configured Linux container CPU quota. Defaults to false.
218+
215219
* `--version`: Prints current CSI external-snapshotter version and quits.
216220

217221
* All glog / klog arguments are supported, such as `-v <log level>` or `-alsologtostderr`.

cmd/csi-snapshotter/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"github.com/kubernetes-csi/csi-lib-utils/leaderelection"
4646
"github.com/kubernetes-csi/csi-lib-utils/metrics"
4747
csirpc "github.com/kubernetes-csi/csi-lib-utils/rpc"
48+
"github.com/kubernetes-csi/csi-lib-utils/standardflags"
4849
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/features"
4950
controller "github.com/kubernetes-csi/external-snapshotter/v8/pkg/sidecar-controller"
5051
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/snapshotter"
@@ -115,6 +116,7 @@ func main() {
115116
c := logsapi.NewLoggingConfiguration()
116117
logsapi.AddGoFlags(c, flag.CommandLine)
117118
logs.InitLogs()
119+
standardflags.AddAutomaxprocs(klog.Infof)
118120
flag.Parse()
119121
if err := logsapi.ValidateAndApply(c, fg); err != nil {
120122
klog.ErrorS(err, "LoggingConfiguration is invalid")

cmd/snapshot-controller/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
klog "k8s.io/klog/v2"
4444

4545
"github.com/kubernetes-csi/csi-lib-utils/leaderelection"
46+
"github.com/kubernetes-csi/csi-lib-utils/standardflags"
4647
controller "github.com/kubernetes-csi/external-snapshotter/v8/pkg/common-controller"
4748
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/features"
4849
"github.com/kubernetes-csi/external-snapshotter/v8/pkg/metrics"
@@ -163,6 +164,7 @@ func main() {
163164
c := logsapi.NewLoggingConfiguration()
164165
logsapi.AddGoFlags(c, flag.CommandLine)
165166
logs.InitLogs()
167+
standardflags.AddAutomaxprocs(klog.Infof)
166168
flag.Parse()
167169
if err := logsapi.ValidateAndApply(c, fg); err != nil {
168170
klog.ErrorS(err, "LoggingConfiguration is invalid")

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ require (
88
github.com/container-storage-interface/spec v1.11.0
99
github.com/evanphx/json-patch v5.9.0+incompatible
1010
github.com/golang/mock v1.6.0
11-
github.com/kubernetes-csi/csi-lib-utils v0.21.0
11+
github.com/kubernetes-csi/csi-lib-utils v0.22.0
1212
github.com/kubernetes-csi/csi-test/v5 v5.3.1
1313
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0
1414
github.com/prometheus/client_golang v1.22.0
1515
github.com/prometheus/client_model v0.6.1
1616
github.com/prometheus/common v0.62.0
1717
google.golang.org/grpc v1.69.0
1818
google.golang.org/protobuf v1.36.5
19-
k8s.io/api v0.33.0
20-
k8s.io/apimachinery v0.33.0
19+
k8s.io/api v0.33.1
20+
k8s.io/apimachinery v0.33.1
2121
k8s.io/apiserver v0.33.0
22-
k8s.io/client-go v0.33.0
23-
k8s.io/component-base v0.33.0
22+
k8s.io/client-go v0.33.1
23+
k8s.io/component-base v0.33.1
2424
k8s.io/component-helpers v0.33.0
2525
k8s.io/klog/v2 v2.130.1
2626
k8s.io/utils v0.0.0-20241210054802-24370beab758
@@ -60,6 +60,7 @@ require (
6060
go.opentelemetry.io/otel v1.33.0 // indirect
6161
go.opentelemetry.io/otel/metric v1.33.0 // indirect
6262
go.opentelemetry.io/otel/trace v1.33.0 // indirect
63+
go.uber.org/automaxprocs v1.6.0 // indirect
6364
go.uber.org/multierr v1.11.0 // indirect
6465
go.uber.org/zap v1.27.0 // indirect
6566
golang.org/x/net v0.39.0 // indirect

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
6363
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
6464
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6565
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
66-
github.com/kubernetes-csi/csi-lib-utils v0.21.0 h1:dUN/iIgXLucAxyML2iPyhniIlACQumIeAJmIzsMBddc=
67-
github.com/kubernetes-csi/csi-lib-utils v0.21.0/go.mod h1:ZCVRTYuup+bwX9tOeE5Q3LDw64QvltSwMUQ3M3g2T+Q=
66+
github.com/kubernetes-csi/csi-lib-utils v0.22.0 h1:EUAs1+uHGps3OtVj4XVx16urhpI02eu+Z8Vps6plpHY=
67+
github.com/kubernetes-csi/csi-lib-utils v0.22.0/go.mod h1:f+PalKyS4Ujsjb9+m6Rj0W6c28y3nfea3paQ/VqjI28=
6868
github.com/kubernetes-csi/csi-test/v5 v5.3.1 h1:Wiukp1In+kif+BFo6q2ExjgB+MbrAz4jZWzGfijypuY=
6969
github.com/kubernetes-csi/csi-test/v5 v5.3.1/go.mod h1:7hA2cSYJ6T8CraEZPA6zqkLZwemjBD54XAnPsPC3VpA=
7070
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
@@ -87,6 +87,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
8787
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8888
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
8989
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
90+
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
91+
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
9092
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
9193
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
9294
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
@@ -127,6 +129,8 @@ go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4Jjx
127129
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
128130
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s=
129131
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck=
132+
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
133+
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
130134
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
131135
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
132136
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=

vendor/github.com/kubernetes-csi/csi-lib-utils/leaderelection/leader_election.go

Lines changed: 21 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/csi-lib-utils/standardflags/automaxprocs.go

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/automaxprocs/LICENSE

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/go.uber.org/automaxprocs/internal/cgroups/cgroup.go

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)