You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/12/15 18:47:05 UTC
[camel-k] branch main updated: feat: Set GOMAXPROCS based on CPU quota
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new a0daa6e feat: Set GOMAXPROCS based on CPU quota
a0daa6e is described below
commit a0daa6eced76657c0a93ecb7617e774daedc842f
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Wed Dec 15 17:48:00 2021 +0100
feat: Set GOMAXPROCS based on CPU quota
---
go.mod | 1 +
go.sum | 1 +
pkg/cmd/operator/operator.go | 5 +++++
3 files changed, 7 insertions(+)
diff --git a/go.mod b/go.mod
index e11b03b..bb740d4 100644
--- a/go.mod
+++ b/go.mod
@@ -40,6 +40,7 @@ require (
github.com/spf13/viper v1.8.1
github.com/stoewer/go-strcase v1.2.0
github.com/stretchr/testify v1.7.0
+ go.uber.org/automaxprocs v1.4.0
go.uber.org/multierr v1.6.0
go.uber.org/zap v1.19.1
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
diff --git a/go.sum b/go.sum
index 74904a0..8e3f6e8 100644
--- a/go.sum
+++ b/go.sum
@@ -1158,6 +1158,7 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4=
diff --git a/pkg/cmd/operator/operator.go b/pkg/cmd/operator/operator.go
index 256d9d5..3741079 100644
--- a/pkg/cmd/operator/operator.go
+++ b/pkg/cmd/operator/operator.go
@@ -27,6 +27,8 @@ import (
"strconv"
"time"
+ "go.uber.org/automaxprocs/maxprocs"
+
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
@@ -89,6 +91,9 @@ func Run(healthPort, monitoringPort int32, leaderElection bool) {
klog.SetLogger(log)
+ _, err := maxprocs.Set(maxprocs.Logger(func(f string, a ...interface{}) { log.Info(fmt.Sprintf(f, a)) }))
+ exitOnError(err, "failed to set GOMAXPROCS from cgroups")
+
printVersion()
watchNamespace, err := getWatchNamespace()