Set GOMAXPROCS explicitly

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2023-03-30 12:19:09 -04:00
parent c3e7eca7fd
commit 5662566e03
5 changed files with 49 additions and 0 deletions

View File

@@ -554,6 +554,19 @@ kube::golang::setup_env() {
# This seems to matter to some tools
export GO15VENDOREXPERIMENT=1
# GOMAXPROCS by default does not reflect the number of cpu(s) available
# when running in a container, please see https://github.com/golang/go/issues/33803
if ! command -v ncpu >/dev/null 2>&1; then
# shellcheck disable=SC2164
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
GO111MODULE=on go install ./ncpu
# shellcheck disable=SC2164
popd >/dev/null
fi
GOMAXPROCS=${GOMAXPROCS:-$(ncpu)}
kube::log::status "Setting GOMAXPROCS: ${GOMAXPROCS}"
}
# This will take binaries from $GOPATH/bin and copy them to the appropriate