Skip to content

Commit 4cef9a0

Browse files
committed
fix(ci): decline unreadable CA pems; stop the probe test masking crashes
Two review findings, and the first exposed a real defect in the probes. The test discarded stderr and forced success, so a probe that CRASHED was indistinguishable from one that deliberately disabled the cache, and every disabled-case assertion would pass on a broken script. It now captures the exit status separately and fails on any non-zero exit, printing the probe's stderr. That immediately surfaced a bug: the probes guarded the TLS path with -z BAZEL_REMOTE_CA_PEM, which only catches an unset variable. A variable set to a path that does not exist fell through to the below and failed the job instead of cleanly declining the cache. The guard is now -r, covering unset and unreadable alike, and the message reports the offending path. Added the two missing cases: TLS with a readable CA pem (the success path that emits --tls_certificate, previously uncovered, asserted to produce both grpcs:// and the certificate flag so a silent downgrade to plaintext cannot pass), and TLS with an unreadable CA path. Six probes, six cases. Every assertion is backed by a negative control, each verified to fail when the defect is reintroduced: dead default host restored, CA guard reverted to -z, TLS downgraded to plaintext, and a probe that exits non-zero. Co-authored-by: Balaji Ganesan <bganesan@nvidia.com>
1 parent d9f3b96 commit 4cef9a0

7 files changed

Lines changed: 86 additions & 23 deletions

File tree

‎src/compute-plane-services/ess-agent/scripts/.bazel-remote-probe‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ else
2424
host="${NVCF_BAZEL_REMOTE_HOST}"
2525
port="${NVCF_BAZEL_REMOTE_PORT:-443}"
2626
tls="${NVCF_BAZEL_REMOTE_TLS:-1}"
27-
if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then
27+
if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then
2828
# TLS requires a CA pem. grpcurl can probe with `-insecure`, but
2929
# Bazel's own gRPC client cannot: with `grpcs://` and no
3030
# `--tls_certificate` it tries the system trust store, which does
3131
# not contain the cache's self-signed cert, and fails mid-build
3232
# with "General OpenSslEngine problem". Skip the cache cleanly
3333
# instead of greenlighting an unusable URL. Hit on
3434
# dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI
35-
# variable) to enable.
36-
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset; remote cache disabled. Set the file-type CI variable to enable."
35+
# variable) to enable. The test is -r, not -z: a variable set to a
36+
# path that does not exist would otherwise reach the `cp` below and
37+
# fail the job instead of cleanly declining the cache.
38+
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset or unreadable (${BAZEL_REMOTE_CA_PEM:-unset}); remote cache disabled. Set the file-type CI variable to enable."
3739
elif [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM}" ]; then
3840
# Env var is set but the file is missing or unreadable. Treat it
3941
# the same as unset and degrade to local-only rather than failing

‎src/compute-plane-services/nvca/scripts/.bazel-remote-probe‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ else
2222
host="${NVCF_BAZEL_REMOTE_HOST}"
2323
port="${NVCF_BAZEL_REMOTE_PORT:-443}"
2424
tls="${NVCF_BAZEL_REMOTE_TLS:-1}"
25-
if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then
25+
if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then
2626
# TLS requires a CA pem. grpcurl can probe with `-insecure`, but
2727
# Bazel's own gRPC client cannot: with `grpcs://` and no
2828
# `--tls_certificate` it tries the system trust store, which does
2929
# not contain the cache's self-signed cert, and fails mid-build
3030
# with "General OpenSslEngine problem". Skip the cache cleanly
3131
# instead of greenlighting an unusable URL. Hit on
3232
# dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI
33-
# variable) to enable.
34-
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset; remote cache disabled. Set the file-type CI variable to enable."
33+
# variable) to enable. The test is -r, not -z: a variable set to a
34+
# path that does not exist would otherwise reach the `cp` below and
35+
# fail the job instead of cleanly declining the cache.
36+
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset or unreadable (${BAZEL_REMOTE_CA_PEM:-unset}); remote cache disabled. Set the file-type CI variable to enable."
3537
else
3638
probe_args=(-d '{"instance_name":""}')
3739
cache_url="grpc://${host}:${port}"

‎src/control-plane-services/function-autoscaler/scripts/.bazel-remote-probe‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ else
2424
host="${NVCF_BAZEL_REMOTE_HOST}"
2525
port="${NVCF_BAZEL_REMOTE_PORT:-443}"
2626
tls="${NVCF_BAZEL_REMOTE_TLS:-1}"
27-
if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then
27+
if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then
2828
# TLS requires a CA pem. grpcurl can probe with `-insecure`, but
2929
# Bazel's own gRPC client cannot: with `grpcs://` and no
3030
# `--tls_certificate` it tries the system trust store, which does
3131
# not contain the cache's self-signed cert, and fails mid-build
3232
# with "General OpenSslEngine problem". Skip the cache cleanly
3333
# instead of greenlighting an unusable URL. Hit on
3434
# dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI
35-
# variable) to enable.
36-
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset; remote cache disabled. Set the file-type CI variable to enable."
35+
# variable) to enable. The test is -r, not -z: a variable set to a
36+
# path that does not exist would otherwise reach the `cp` below and
37+
# fail the job instead of cleanly declining the cache.
38+
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset or unreadable (${BAZEL_REMOTE_CA_PEM:-unset}); remote cache disabled. Set the file-type CI variable to enable."
3739
elif [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM}" ]; then
3840
# Env var is set but the file is missing or unreadable. Treat it
3941
# the same as unset and degrade to local-only rather than failing

‎src/control-plane-services/helm-reval/scripts/.bazel-remote-probe‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ else
2222
host="${NVCF_BAZEL_REMOTE_HOST}"
2323
port="${NVCF_BAZEL_REMOTE_PORT:-443}"
2424
tls="${NVCF_BAZEL_REMOTE_TLS:-1}"
25-
if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then
25+
if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then
2626
# TLS requires a CA pem. grpcurl can probe with `-insecure`, but
2727
# Bazel's own gRPC client cannot: with `grpcs://` and no
2828
# `--tls_certificate` it tries the system trust store, which does
2929
# not contain the cache's self-signed cert, and fails mid-build
3030
# with "General OpenSslEngine problem". Skip the cache cleanly
3131
# instead of greenlighting an unusable URL. Hit on
3232
# dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI
33-
# variable) to enable.
34-
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset; remote cache disabled. Set the file-type CI variable to enable."
33+
# variable) to enable. The test is -r, not -z: a variable set to a
34+
# path that does not exist would otherwise reach the `cp` below and
35+
# fail the job instead of cleanly declining the cache.
36+
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset or unreadable (${BAZEL_REMOTE_CA_PEM:-unset}); remote cache disabled. Set the file-type CI variable to enable."
3537
else
3638
probe_args=(-d '{"instance_name":""}')
3739
cache_url="grpc://${host}:${port}"

‎src/invocation-plane-services/http-invocation/scripts/.bazel-remote-probe‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ else
2424
host="${NVCF_BAZEL_REMOTE_HOST}"
2525
port="${NVCF_BAZEL_REMOTE_PORT:-443}"
2626
tls="${NVCF_BAZEL_REMOTE_TLS:-1}"
27-
if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then
27+
if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then
2828
# TLS requires a CA pem. grpcurl can probe with `-insecure`, but
2929
# Bazel's own gRPC client cannot: with `grpcs://` and no
3030
# `--tls_certificate` it tries the system trust store, which does
3131
# not contain the cache's self-signed cert, and fails mid-build
3232
# with "General OpenSslEngine problem". Skip the cache cleanly
3333
# instead of greenlighting an unusable URL. Hit on
3434
# dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI
35-
# variable) to enable.
36-
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset; remote cache disabled. Set the file-type CI variable to enable."
35+
# variable) to enable. The test is -r, not -z: a variable set to a
36+
# path that does not exist would otherwise reach the `cp` below and
37+
# fail the job instead of cleanly declining the cache.
38+
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset or unreadable (${BAZEL_REMOTE_CA_PEM:-unset}); remote cache disabled. Set the file-type CI variable to enable."
3739
elif [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM}" ]; then
3840
# Env var is set but the file is missing or unreadable. Treat it
3941
# the same as unset and degrade to local-only rather than failing

‎src/invocation-plane-services/llm-api-gateway/scripts/.bazel-remote-probe‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ else
2424
host="${NVCF_BAZEL_REMOTE_HOST}"
2525
port="${NVCF_BAZEL_REMOTE_PORT:-443}"
2626
tls="${NVCF_BAZEL_REMOTE_TLS:-1}"
27-
if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then
27+
if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then
2828
# TLS requires a CA pem. grpcurl can probe with `-insecure`, but
2929
# Bazel's own gRPC client cannot: with `grpcs://` and no
3030
# `--tls_certificate` it tries the system trust store, which does
3131
# not contain the cache's self-signed cert, and fails mid-build
3232
# with "General OpenSslEngine problem". Skip the cache cleanly
3333
# instead of greenlighting an unusable URL. Hit on
3434
# dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI
35-
# variable) to enable.
36-
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset; remote cache disabled. Set the file-type CI variable to enable."
35+
# variable) to enable. The test is -r, not -z: a variable set to a
36+
# path that does not exist would otherwise reach the `cp` below and
37+
# fail the job instead of cleanly declining the cache.
38+
echo "[bazel-remote] grpcs://${host}:${port} requested but BAZEL_REMOTE_CA_PEM is unset or unreadable (${BAZEL_REMOTE_CA_PEM:-unset}); remote cache disabled. Set the file-type CI variable to enable."
3739
elif [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM}" ]; then
3840
# Env var is set but the file is missing or unreadable. Treat it
3941
# the same as unset and degrade to local-only rather than failing

‎tools/ci/test-bazel-remote-probe‎

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,56 @@ echo '{"cacheCapabilities":{"supportedCompressors":["IDENTITY","ZSTD"]}}'
2323
STUB
2424
chmod +x "${stub_dir}/grpcurl"
2525

26+
# A readable (contents irrelevant) CA pem for the TLS success path.
27+
ca_pem="${stub_dir}/ca.pem"
28+
printf -- '-----BEGIN CERTIFICATE-----\nstub\n-----END CERTIFICATE-----\n' > "${ca_pem}"
29+
2630
fail=0
2731

2832
check() { # name, expectation (enabled|disabled), probe, env assignments...
2933
local name="$1" want="$2" probe="$3"; shift 3
30-
local out
34+
local out status svc
35+
svc="$(basename "$(dirname "$(dirname "${probe}")")")"
36+
37+
# Capture stdout and the exit status separately. Discarding stderr and
38+
# forcing success would let a probe that CRASHES look identical to one that
39+
# deliberately disables the cache, so every disabled-case assertion would
40+
# pass on a broken script.
41+
set +e
3142
out="$(
3243
env -i PATH="${stub_dir}:/usr/bin:/bin" HOME="${stub_dir}" \
3344
CI_PROJECT_DIR="${stub_dir}" "$@" \
34-
bash -c 'BAZEL_REMOTE_FLAGS=""; . "$0"; printf "%s" "${BAZEL_REMOTE_FLAGS}"' "${probe}" 2>/dev/null
35-
)" || true
45+
bash -c 'set -e; BAZEL_REMOTE_FLAGS=""; . "$0"; printf "%s" "${BAZEL_REMOTE_FLAGS}"' \
46+
"${probe}" 2>"${stub_dir}/stderr.txt"
47+
)"
48+
status=$?
49+
set -e
50+
51+
if [[ "${status}" -ne 0 ]]; then
52+
printf ' FAIL %-26s %-11s probe exited %s (expected a clean %s decision)\n' \
53+
"${svc}" "${name}" "${status}" "${want}" >&2
54+
sed 's/^/ /' "${stub_dir}/stderr.txt" >&2 || true
55+
fail=1
56+
return
57+
fi
58+
3659
local got="disabled"
3760
[[ "${out}" == *--remote_cache=* ]] && got="enabled"
3861
if [[ "${got}" != "${want}" ]]; then
39-
printf ' FAIL %-34s %-9s want=%s got=%s\n' "$(basename "$(dirname "$(dirname "${probe}")")")" "${name}" "${want}" "${got}" >&2
62+
printf ' FAIL %-26s %-11s want=%s got=%s\n' "${svc}" "${name}" "${want}" "${got}" >&2
4063
fail=1
64+
return
65+
fi
66+
67+
# For the TLS-enabled case, the cache URL must be grpcs:// and the probe must
68+
# emit --tls_certificate. Without this the case would pass on a probe that
69+
# silently downgraded to plaintext.
70+
if [[ "${name}" == "tls-with-ca" ]]; then
71+
if [[ "${out}" != *--tls_certificate=* || "${out}" != *grpcs://* ]]; then
72+
printf ' FAIL %-26s %-11s expected grpcs:// and --tls_certificate, got: %s\n' \
73+
"${svc}" "${name}" "${out}" >&2
74+
fail=1
75+
fi
4176
fi
4277
}
4378

@@ -72,13 +107,29 @@ for probe in "${probes[@]}"; do
72107
NVCF_BAZEL_REMOTE_PORT=8980 NVCF_BAZEL_REMOTE_TLS=0
73108

74109
# TLS requested but no CA pem: must decline rather than emit an unusable URL.
110+
# Bazel's gRPC client cannot verify a private cache cert from the system
111+
# trust store, so a grpcs:// URL without --tls_certificate fails mid-build.
75112
check "tls-no-ca" disabled "${probe}" \
76113
NVCF_BAZEL_REMOTE=1 NVCF_BAZEL_REMOTE_HOST=cache.example.com \
77114
NVCF_BAZEL_REMOTE_PORT=443 NVCF_BAZEL_REMOTE_TLS=1
115+
116+
# TLS requested WITH a readable CA pem: the success path that actually emits
117+
# the certificate flag. Without this case nothing covers the grpcs:// branch.
118+
check "tls-with-ca" enabled "${probe}" \
119+
NVCF_BAZEL_REMOTE=1 NVCF_BAZEL_REMOTE_HOST=cache.example.com \
120+
NVCF_BAZEL_REMOTE_PORT=443 NVCF_BAZEL_REMOTE_TLS=1 \
121+
BAZEL_REMOTE_CA_PEM="${ca_pem}"
122+
123+
# TLS requested with an UNREADABLE CA path: must decline, not emit a flag
124+
# pointing at a file that does not exist.
125+
check "tls-bad-ca" disabled "${probe}" \
126+
NVCF_BAZEL_REMOTE=1 NVCF_BAZEL_REMOTE_HOST=cache.example.com \
127+
NVCF_BAZEL_REMOTE_PORT=443 NVCF_BAZEL_REMOTE_TLS=1 \
128+
BAZEL_REMOTE_CA_PEM="${stub_dir}/definitely-missing.pem"
78129
done
79130

80131
if [[ "${fail}" -ne 0 ]]; then
81132
echo "bazel-remote-probe behavioral tests failed" >&2
82133
exit 1
83134
fi
84-
echo "bazel-remote-probe: ${#probes[@]} probes x 4 cases OK"
135+
echo "bazel-remote-probe: ${#probes[@]} probes x 6 cases OK"

0 commit comments

Comments
 (0)