Skip to content

Commit 03ee07c

Browse files
authored
Merge pull request #499 from nixpanic/automaxprocs
Add `-automaxprocs` flag for configuring `GOMAXPROCS`
2 parents bf35435 + e616f3c commit 03ee07c

File tree

20 files changed

+1204
-24
lines changed

20 files changed

+1204
-24
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Note that the external-resizer does not scale with more replicas. Only one exter
9696

9797
* `--metrics-address`: (deprecated) The TCP network address where the prometheus metrics endpoint will run (example: `:8080` which corresponds to port 8080 on local host). The default is empty string, which means metrics endpoint is disabled.
9898

99+
* `--automaxprocs`: Automatically set the `GOMAXPROCS` environment variable to match the configured Linux container CPU quota. Defaults to false.
100+
99101
* `--version`: Prints current external-resizer version and quits.
100102

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

cmd/csi-resizer/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"k8s.io/client-go/util/workqueue"
3535

3636
"github.com/kubernetes-csi/csi-lib-utils/leaderelection"
37+
"github.com/kubernetes-csi/csi-lib-utils/standardflags"
3738
"github.com/kubernetes-csi/external-resizer/pkg/controller"
3839
"github.com/kubernetes-csi/external-resizer/pkg/features"
3940
"github.com/kubernetes-csi/external-resizer/pkg/modifier"
@@ -101,6 +102,7 @@ func main() {
101102
c := logsapi.NewLoggingConfiguration()
102103
logsapi.AddGoFlags(c, flag.CommandLine)
103104
logs.InitLogs()
105+
standardflags.AddAutomaxprocs(klog.Infof)
104106
flag.Parse()
105107
if err := logsapi.ValidateAndApply(c, fg); err != nil {
106108
klog.ErrorS(err, "LoggingConfiguration is invalid")

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ toolchain go1.24.3
77
require (
88
github.com/container-storage-interface/spec v1.11.0
99
github.com/google/go-cmp v0.7.0
10-
github.com/kubernetes-csi/csi-lib-utils v0.21.0
10+
github.com/kubernetes-csi/csi-lib-utils v0.22.0
1111
golang.org/x/oauth2 v0.27.0 // indirect
1212
golang.org/x/term v0.31.0 // indirect
1313
google.golang.org/grpc v1.69.2
14-
k8s.io/api v0.33.0
15-
k8s.io/apimachinery v0.33.0
14+
k8s.io/api v0.33.1
15+
k8s.io/apimachinery v0.33.1
1616
k8s.io/apiserver v0.33.0
17-
k8s.io/client-go v0.33.0
18-
k8s.io/component-base v0.33.0
17+
k8s.io/client-go v0.33.1
18+
k8s.io/component-base v0.33.1
1919
k8s.io/csi-translation-lib v0.33.0
2020
k8s.io/klog/v2 v2.130.1
2121
)
@@ -56,6 +56,7 @@ require (
5656
go.opentelemetry.io/otel v1.33.0 // indirect
5757
go.opentelemetry.io/otel/metric v1.33.0 // indirect
5858
go.opentelemetry.io/otel/trace v1.33.0 // indirect
59+
go.uber.org/automaxprocs v1.6.0 // indirect
5960
go.uber.org/multierr v1.11.0 // indirect
6061
go.uber.org/zap v1.27.0 // indirect
6162
golang.org/x/net v0.39.0 // indirect

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
5858
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
5959
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6060
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
61-
github.com/kubernetes-csi/csi-lib-utils v0.21.0 h1:dUN/iIgXLucAxyML2iPyhniIlACQumIeAJmIzsMBddc=
62-
github.com/kubernetes-csi/csi-lib-utils v0.21.0/go.mod h1:ZCVRTYuup+bwX9tOeE5Q3LDw64QvltSwMUQ3M3g2T+Q=
61+
github.com/kubernetes-csi/csi-lib-utils v0.22.0 h1:EUAs1+uHGps3OtVj4XVx16urhpI02eu+Z8Vps6plpHY=
62+
github.com/kubernetes-csi/csi-lib-utils v0.22.0/go.mod h1:f+PalKyS4Ujsjb9+m6Rj0W6c28y3nfea3paQ/VqjI28=
6363
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
6464
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
6565
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
@@ -80,6 +80,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
8080
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8181
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
8282
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
83+
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
84+
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
8385
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
8486
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
8587
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
@@ -119,6 +121,8 @@ go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4Jjx
119121
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
120122
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s=
121123
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck=
124+
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
125+
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
122126
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
123127
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
124128
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)