mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-20 09:05:26 +00:00
Make gomaxprocs install optional, limit to tests
This commit is contained in:
parent
8cb979ae55
commit
bd36be0218
@ -556,20 +556,25 @@ kube::golang::setup_env() {
|
|||||||
|
|
||||||
# This seems to matter to some tools
|
# This seems to matter to some tools
|
||||||
export GO15VENDOREXPERIMENT=1
|
export GO15VENDOREXPERIMENT=1
|
||||||
|
}
|
||||||
|
|
||||||
|
kube::golang::setup_gomaxprocs() {
|
||||||
# GOMAXPROCS by default does not reflect the number of cpu(s) available
|
# 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
|
# when running in a container, please see https://github.com/golang/go/issues/33803
|
||||||
if ! command -v ncpu >/dev/null 2>&1; then
|
if [[ -z "${GOMAXPROCS:-}" ]]; then
|
||||||
# shellcheck disable=SC2164
|
if ! command -v ncpu >/dev/null 2>&1; then
|
||||||
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
# shellcheck disable=SC2164
|
||||||
GO111MODULE=on go install ./ncpu
|
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
||||||
# shellcheck disable=SC2164
|
GO111MODULE=on go install ./ncpu || echo "Will not automatically set GOMAXPROCS"
|
||||||
popd >/dev/null
|
# shellcheck disable=SC2164
|
||||||
|
popd >/dev/null
|
||||||
|
fi
|
||||||
|
if command -v ncpu >/dev/null 2>&1; then
|
||||||
|
GOMAXPROCS=$(ncpu)
|
||||||
|
export GOMAXPROCS
|
||||||
|
kube::log::status "Set GOMAXPROCS automatically to ${GOMAXPROCS}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GOMAXPROCS=${GOMAXPROCS:-$(ncpu)}
|
|
||||||
export GOMAXPROCS
|
|
||||||
kube::log::status "Setting GOMAXPROCS: ${GOMAXPROCS}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This will take binaries from $GOPATH/bin and copy them to the appropriate
|
# This will take binaries from $GOPATH/bin and copy them to the appropriate
|
||||||
|
@ -18,6 +18,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
|
|||||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||||
|
|
||||||
kube::golang::setup_env
|
kube::golang::setup_env
|
||||||
|
kube::golang::setup_gomaxprocs
|
||||||
|
|
||||||
# start the cache mutation detector by default so that cache mutators will be found
|
# start the cache mutation detector by default so that cache mutators will be found
|
||||||
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}"
|
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}"
|
||||||
|
@ -22,6 +22,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
|
|||||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||||
|
|
||||||
kube::golang::setup_env
|
kube::golang::setup_env
|
||||||
|
kube::golang::setup_gomaxprocs
|
||||||
|
|
||||||
# start the cache mutation detector by default so that cache mutators will be found
|
# start the cache mutation detector by default so that cache mutators will be found
|
||||||
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}"
|
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}"
|
||||||
|
Loading…
Reference in New Issue
Block a user