From 25e5387e07afa6b2af3303364687eea471795c1e Mon Sep 17 00:00:00 2001 From: Anya Sabo <1638148+anyasabo@users.noreply.github.com> Date: Fri, 20 Mar 2020 22:30:55 -0500 Subject: [PATCH] Add automaxprocs (#2724) --- .golangci.yml | 2 +- NOTICE.txt | 40 +++++++++++++++++++++++----- cmd/manager/main.go | 8 ++++++ docs/reference/dependencies.asciidoc | 5 ++-- go.mod | 1 + go.sum | 4 +++ 6 files changed, 51 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f829b2421a..fc6bc0c6d0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,7 +38,7 @@ issues: - stylecheck text: 'ST1016: methods on the same type should have the same receiver name .*' - path: cmd/manager/main\.go - text: 'cyclomatic complexity 31 of func `execute` is high (> 30)' + text: 'cyclomatic complexity \d+ of func `execute` is high' - path: pkg/controller/apmserver/config/reconcile\.go text: 'G101: Potential hardcoded credentials' - path: pkg/controller/common/settings/canonical_config\.go diff --git a/NOTICE.txt b/NOTICE.txt index a5c1b9a57a..604cb2a055 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2221,6 +2221,34 @@ Contents of probable licence file $GOMODCACHE/go.elastic.co/apm/module/apmelasti limitations under the License. +-------------------------------------------------------------------------------- +Module : go.uber.org/automaxprocs +Version : v1.3.0 +Time : 2020-01-23T19:41:49Z +Licence : MIT + +Contents of probable licence file $GOMODCACHE/go.uber.org/automaxprocs@v1.3.0/LICENSE: + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + -------------------------------------------------------------------------------- Module : go.uber.org/zap Version : v1.12.0 @@ -26433,11 +26461,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Module : golang.org/x/lint -Version : v0.0.0-20190930215403-16217165b5de -Time : 2019-09-30T21:54:03Z +Version : v0.0.0-20191125180803-fdd1cda4f05f +Time : 2019-11-25T18:08:03Z Licence : BSD-3-Clause -Contents of probable licence file $GOMODCACHE/golang.org/x/lint@v0.0.0-20190930215403-16217165b5de/LICENSE: +Contents of probable licence file $GOMODCACHE/golang.org/x/lint@v0.0.0-20191125180803-fdd1cda4f05f/LICENSE: Copyright (c) 2013 The Go Authors. All rights reserved. @@ -26766,11 +26794,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- Module : golang.org/x/tools -Version : v0.0.0-20191029190741-b9c20aec41a5 -Time : 2019-10-29T19:07:41Z +Version : v0.0.0-20191125144606-a911d9008d1f +Time : 2019-11-25T14:46:06Z Licence : BSD-3-Clause -Contents of probable licence file $GOMODCACHE/golang.org/x/tools@v0.0.0-20191029190741-b9c20aec41a5/LICENSE: +Contents of probable licence file $GOMODCACHE/golang.org/x/tools@v0.0.0-20191125144606-a911d9008d1f/LICENSE: Copyright (c) 2009 The Go Authors. All rights reserved. diff --git a/cmd/manager/main.go b/cmd/manager/main.go index aecf99b481..b53f9f8a41 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -56,6 +56,7 @@ import ( licensing "github.com/elastic/cloud-on-k8s/pkg/license" "github.com/elastic/cloud-on-k8s/pkg/utils/net" "github.com/elastic/cloud-on-k8s/pkg/utils/rbac" + "go.uber.org/automaxprocs/maxprocs" "k8s.io/apimachinery/pkg/util/wait" ) @@ -180,6 +181,13 @@ func init() { } func execute() { + // update GOMAXPROCS to container cpu limit if necessary + _, err := maxprocs.Set(maxprocs.Logger(log.Info)) + if err != nil { + log.Error(err, "Error setting GOMAXPROCS") + os.Exit(1) + } + if dev.Enabled { // expose pprof if development mode is enabled mux := http.NewServeMux() diff --git a/docs/reference/dependencies.asciidoc b/docs/reference/dependencies.asciidoc index 6daa2c84df..cdb175d973 100644 --- a/docs/reference/dependencies.asciidoc +++ b/docs/reference/dependencies.asciidoc @@ -39,6 +39,7 @@ This page lists the third-party dependencies used to build {n}. | link:https://github.com/tsenart/vegeta[$$github.com/tsenart/vegeta$$] | v12.7.0+incompatible | MIT | link:https://go.elastic.co/apm[$$go.elastic.co/apm$$] | v1.7.0 | Apache-2.0 | link:https://go.elastic.co/apm/module/apmelasticsearch[$$go.elastic.co/apm/module/apmelasticsearch$$] | v1.7.0 | Apache-2.0 +| link:https://go.uber.org/automaxprocs[$$go.uber.org/automaxprocs$$] | v1.3.0 | MIT | link:https://go.uber.org/zap[$$go.uber.org/zap$$] | v1.12.0 | MIT | link:https://golang.org/x/crypto[$$golang.org/x/crypto$$] | v0.0.0-20191011191535-87dc89f01550 | BSD-3-Clause | link:https://gopkg.in/yaml.v2[$$gopkg.in/yaml.v2$$] | v2.2.5 | Apache-2.0 @@ -257,7 +258,7 @@ This page lists the third-party dependencies used to build {n}. | link:https://go.uber.org/tools[$$go.uber.org/tools$$] | v0.0.0-20190618225709-2cfd321de3ee | MIT | link:https://golang.org/x/exp[$$golang.org/x/exp$$] | v0.0.0-20190312203227-4b39c73a6495 | BSD-3-Clause | link:https://golang.org/x/image[$$golang.org/x/image$$] | v0.0.0-20190227222117-0694c2d4d067 | BSD-3-Clause -| link:https://golang.org/x/lint[$$golang.org/x/lint$$] | v0.0.0-20190930215403-16217165b5de | BSD-3-Clause +| link:https://golang.org/x/lint[$$golang.org/x/lint$$] | v0.0.0-20191125180803-fdd1cda4f05f | BSD-3-Clause | link:https://golang.org/x/mobile[$$golang.org/x/mobile$$] | v0.0.0-20190312151609-d3739f865fa6 | BSD-3-Clause | link:https://golang.org/x/mod[$$golang.org/x/mod$$] | v0.0.0-20190513183733-4bf6d317e70e | BSD-3-Clause | link:https://golang.org/x/net[$$golang.org/x/net$$] | v0.0.0-20191011234655-491137f69257 | BSD-3-Clause @@ -266,7 +267,7 @@ This page lists the third-party dependencies used to build {n}. | link:https://golang.org/x/sys[$$golang.org/x/sys$$] | v0.0.0-20191204072324-ce4227a45e2e | BSD-3-Clause | link:https://golang.org/x/text[$$golang.org/x/text$$] | v0.3.2 | BSD-3-Clause | link:https://golang.org/x/time[$$golang.org/x/time$$] | v0.0.0-20190921001708-c4c64cad1fd0 | BSD-3-Clause -| link:https://golang.org/x/tools[$$golang.org/x/tools$$] | v0.0.0-20191029190741-b9c20aec41a5 | BSD-3-Clause +| link:https://golang.org/x/tools[$$golang.org/x/tools$$] | v0.0.0-20191125144606-a911d9008d1f | BSD-3-Clause | link:https://golang.org/x/xerrors[$$golang.org/x/xerrors$$] | v0.0.0-20191011141410-1b5146add898 | BSD-3-Clause | link:https://gomodules.xyz/jsonpatch/v2[$$gomodules.xyz/jsonpatch/v2$$] | v2.0.1 | Apache-2.0 | link:https://github.com/gonum/gonum[$$gonum.org/v1/gonum$$] | v0.0.0-20190331200053-3d26580ed485 | BSD-3-Clause diff --git a/go.mod b/go.mod index 2c850b3893..9a8387cd3e 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,7 @@ require ( github.com/tsenart/vegeta v12.7.0+incompatible go.elastic.co/apm v1.7.0 go.elastic.co/apm/module/apmelasticsearch v1.7.0 + go.uber.org/automaxprocs v1.3.0 go.uber.org/zap v1.12.0 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 golang.org/x/net v0.0.0-20191011234655-491137f69257 // indirect diff --git a/go.sum b/go.sum index 38a5e16994..2bbdab8e79 100644 --- a/go.sum +++ b/go.sum @@ -490,6 +490,8 @@ go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/automaxprocs v1.3.0 h1:II28aZoGdaglS5vVNnspf28lnZpXScxtIozx1lAjdb0= +go.uber.org/automaxprocs v1.3.0/go.mod h1:9CWT6lKIep8U41DDaPiH6eFscnTyjfTANNQNx6LrIcA= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0 h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc= @@ -524,6 +526,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -625,6 +628,7 @@ golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=