|
2 | 2 | # SPDX-FileCopyrightText: Copyright (c) NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | 4 | # |
5 | | -# Probe the nvcfbarn remote cache and export BAZEL_REMOTE_FLAGS with the |
| 5 | +# Probe the configured remote cache and export BAZEL_REMOTE_FLAGS with the |
6 | 6 | # right --remote_cache + --tls_certificate flags, or empty if the cache is |
7 | 7 | # unreachable / disabled. Source this file (do NOT execute it) so the |
8 | 8 | # exported var is visible in the parent shell. |
9 | 9 | # |
10 | 10 | # Driven by four CI/CD variables; all default to safe values that fall back |
11 | 11 | # to local-only cleanly: |
12 | 12 | # NVCF_BAZEL_REMOTE "1" to enable, "0" to disable (default 1). |
13 | | -# NVCF_BAZEL_REMOTE_HOST cache host (default nvcfbarn.nvidia.com). |
| 13 | +# NVCF_BAZEL_REMOTE_HOST cache host. Unset disables the cache (no default: |
| 14 | +# the previous default host was decommissioned). |
14 | 15 | # NVCF_BAZEL_REMOTE_PORT cache port (443 for the TLS sidecar). |
15 | 16 | # NVCF_BAZEL_REMOTE_TLS "1" to use grpcs:// + --tls_certificate (default 1). |
16 | 17 | # BAZEL_REMOTE_CA_PEM File-type CI variable holding the cache's PEM cert. |
17 | 18 | # Required when TLS=1. |
18 | 19 |
|
19 | 20 | BAZEL_REMOTE_FLAGS="" |
20 | | -if [ "${NVCF_BAZEL_REMOTE:-1}" != "1" ]; then |
21 | | - echo "[bazel-remote] NVCF_BAZEL_REMOTE=${NVCF_BAZEL_REMOTE:-unset}; remote cache disabled" |
| 21 | +if [ "${NVCF_BAZEL_REMOTE:-1}" != "1" ] || [ -z "${NVCF_BAZEL_REMOTE_HOST:-}" ]; then |
| 22 | + echo "[bazel-remote] remote cache disabled (NVCF_BAZEL_REMOTE=${NVCF_BAZEL_REMOTE:-unset}, NVCF_BAZEL_REMOTE_HOST=${NVCF_BAZEL_REMOTE_HOST:-unset}); building local-only" |
22 | 23 | else |
23 | | - host="${NVCF_BAZEL_REMOTE_HOST:-nvcfbarn.nvidia.com}" |
| 24 | + host="${NVCF_BAZEL_REMOTE_HOST}" |
24 | 25 | port="${NVCF_BAZEL_REMOTE_PORT:-443}" |
25 | 26 | tls="${NVCF_BAZEL_REMOTE_TLS:-1}" |
26 | | - if [ "${tls}" = "1" ] && [ -z "${BAZEL_REMOTE_CA_PEM:-}" ]; then |
| 27 | + if [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM:-}" ]; then |
27 | 28 | # TLS requires a CA pem. grpcurl can probe with `-insecure`, but |
28 | 29 | # Bazel's own gRPC client cannot: with `grpcs://` and no |
29 | 30 | # `--tls_certificate` it tries the system trust store, which does |
30 | | - # not contain the nvcfbarn self-signed cert, and fails mid-build |
| 31 | + # not contain the cache's self-signed cert, and fails mid-build |
31 | 32 | # with "General OpenSslEngine problem". Skip the cache cleanly |
32 | 33 | # instead of greenlighting an unusable URL. Hit on |
33 | 34 | # dns-cache/nvcf-unbound!41; set BAZEL_REMOTE_CA_PEM (file-type CI |
34 | | - # variable) to enable. |
35 | | - 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." |
36 | 39 | elif [ "${tls}" = "1" ] && [ ! -r "${BAZEL_REMOTE_CA_PEM}" ]; then |
37 | 40 | # Env var is set but the file is missing or unreadable. Treat it |
38 | 41 | # the same as unset and degrade to local-only rather than failing |
|
0 commit comments