From 32cb89d412e6f06fc873b4cd5bb78b39f99e1276 Mon Sep 17 00:00:00 2001 From: Alison Shao <54658187+alisonshao@users.noreply.github.com> Date: Sat, 11 Jul 2026 03:01:23 -0700 Subject: [PATCH] ci: prune uv cache in job teardown to bound its growth (#30813) --- scripts/ci/cuda/ci_cleanup_venv.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/ci/cuda/ci_cleanup_venv.sh b/scripts/ci/cuda/ci_cleanup_venv.sh index c7ce8c783..92269d54c 100755 --- a/scripts/ci/cuda/ci_cleanup_venv.sh +++ b/scripts/ci/cuda/ci_cleanup_venv.sh @@ -10,6 +10,24 @@ set +e set -u +# Bound the persistent uv cache (~/.cache/uv, bind-mounted and shared across all +# runner containers). Nothing else evicts it, so it grows unbounded — on the 5090 +# hosts it reached ~500 GB and filled the disk, failing jobs with ENOSPC at +# dependency install. Prune only under real disk pressure so healthy jobs pay +# nothing (just a df check) and no rebuildable wheel is dropped until it matters: +# `uv cache prune --ci` keeps downloaded wheels + sdist archives (no re-download) +# but drops built wheels, so a later install may recompile source-built packages. +# Best effort; runs regardless of venv mode; never fails the job. +if command -v uv >/dev/null 2>&1; then + cache_dir="$(uv cache dir 2>/dev/null || echo "${HOME:-/root}/.cache/uv")" + [ -d "$cache_dir" ] || cache_dir=/ + used="$(df --output=pcent "$cache_dir" 2>/dev/null | tr -dc '0-9')" + if [ "${used:-0}" -ge 85 ]; then + echo "uv cache filesystem at ${used}% — pruning" + uv cache prune --ci >/dev/null 2>&1 || true + fi +fi + # Skip entirely when venv mode is disabled — no /tmp/sglang-ci-* dir exists # and there's nothing to sweep. Matches the USE_VENV parsing in # ci_install_dependency.sh (accepts 1/true/yes, case-insensitive).