Make Namespace cache setup fail open
This commit is contained in:
parent
dba641035b
commit
2da04bc317
2 changed files with 29 additions and 13 deletions
|
|
@ -19,6 +19,16 @@ portable_mkdir() {
|
|||
command -p mkdir "$@"
|
||||
}
|
||||
|
||||
optional_timeout() {
|
||||
local duration="$1"
|
||||
shift
|
||||
if command -v timeout >/dev/null 2>&1; then
|
||||
timeout "$duration" "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
append_bazel_storage_cache() {
|
||||
local bazelrc_path="$1"
|
||||
local cache_root="${BURROW_BAZEL_STORAGE_CACHE:-}"
|
||||
|
|
@ -61,7 +71,9 @@ configure_bazel_remote_cache() {
|
|||
local bazelrc_path
|
||||
bazelrc_path="${NSC_BAZELRC_PATH:-${TMPDIR:-/tmp}/burrow-nsc-cache.bazelrc}"
|
||||
portable_mkdir -p "$(dirname "$bazelrc_path")"
|
||||
if nsc auth check-login >/dev/null 2>&1 && nsc cache bazel setup --bazelrc "$bazelrc_path" >/dev/null 2>&1; then
|
||||
local probe_timeout="${BURROW_NSC_CACHE_PROBE_TIMEOUT:-30s}"
|
||||
if optional_timeout "$probe_timeout" nsc auth check-login >/dev/null 2>&1 &&
|
||||
optional_timeout "$probe_timeout" nsc cache bazel setup --bazelrc "$bazelrc_path" >/dev/null 2>&1; then
|
||||
append_bazel_storage_cache "$bazelrc_path"
|
||||
export BURROW_BAZEL_NSCCACHE_BAZELRC="$bazelrc_path"
|
||||
export BURROW_BAZEL_NSCCACHE_ACTIVE=1
|
||||
|
|
@ -122,18 +134,6 @@ if [[ -n "${GITHUB_ENV:-}" ]]; then
|
|||
echo "NSC_CACHE_PATH=$cache_root" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
spacectl_bin_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/spacectl-bin"
|
||||
if ! command -v spacectl >/dev/null 2>&1; then
|
||||
if ! bash Scripts/ci/ensure-spacectl.sh; then
|
||||
echo "::warning ::Unable to install spacectl; skipping filesystem cache mount."
|
||||
configure_bazel_remote_cache
|
||||
exit 0
|
||||
fi
|
||||
if [[ -x "${spacectl_bin_dir}/spacectl" ]]; then
|
||||
export PATH="${spacectl_bin_dir}:$PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
mode_args=()
|
||||
for mode in "$@"; do
|
||||
[[ -z "$mode" ]] && continue
|
||||
|
|
@ -157,6 +157,18 @@ if [[ "${#mode_args[@]}" -eq 0 ]]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
spacectl_bin_dir="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/spacectl-bin"
|
||||
if ! command -v spacectl >/dev/null 2>&1; then
|
||||
if ! bash Scripts/ci/ensure-spacectl.sh; then
|
||||
echo "::warning ::Unable to install spacectl; skipping filesystem cache mount."
|
||||
configure_bazel_remote_cache
|
||||
exit 0
|
||||
fi
|
||||
if [[ -x "${spacectl_bin_dir}/spacectl" ]]; then
|
||||
export PATH="${spacectl_bin_dir}:$PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
portable_mkdir -p "$cache_root" 2>/dev/null || true
|
||||
|
||||
args=(-o json cache mount "--dry_run=false" "--cache_root=${cache_root}" "${mode_args[@]}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue