Merge pull request #132210 from dims/add-a-toggle-adding-disabling-grpcnotrace-tag

Adding `grpcnotrace` tag for production (non-debug) builds
This commit is contained in:
Kubernetes Prow Robot
2025-06-11 15:58:54 -07:00
committed by GitHub

View File

@@ -836,7 +836,7 @@ kube::golang::build_binaries_for_platform() {
done
V=2 kube::log::info "Env for ${platform}: GOPATH=${GOPATH-} GOOS=${GOOS-} GOARCH=${GOARCH-} GOROOT=${GOROOT-} CGO_ENABLED=${CGO_ENABLED-} CC=${CC-}"
V=3 kube::log::info "Building binaries with GCFLAGS=${gogcflags} LDFLAGS=${goldflags}"
V=3 kube::log::info "Building binaries with GCFLAGS=${gogcflags} LDFLAGS=${goldflags} and -tags=${gotags:-}"
local -a build_args
if [[ "${#statics[@]}" != 0 ]]; then
@@ -927,6 +927,9 @@ kube::golang::build_binaries() {
gogcflags="${GOGCFLAGS:-}"
goldflags="all=$(kube::version::ldflags) ${GOLDFLAGS:-}"
local grpcnotrace
grpcnotrace=""
if [[ "${DBG:-}" == 1 ]]; then
# Debugging - disable optimizations and inlining and trimPath
gogcflags="${gogcflags} all=-N -l"
@@ -934,10 +937,12 @@ kube::golang::build_binaries() {
# Not debugging - disable symbols and DWARF, trim embedded paths
goldflags="${goldflags} -s -w"
goflags+=("-trimpath")
# build non-debug binaries with "grpcnotrace" tag to avoid x/net trace usage and enable dead code elimination
grpcnotrace=",grpcnotrace"
fi
# Extract tags if any specified in GOFLAGS
gotags="selinux,notest,$(echo "${GOFLAGS:-}" | sed -ne 's|.*-tags=\([^-]*\).*|\1|p')"
gotags="selinux,notest${grpcnotrace},$(echo "${GOFLAGS:-}" | sed -ne 's|.*-tags=\([^-]*\).*|\1|p')"
local -a targets=()
local arg