From 9866c772562036a249f1e28a6e4c5fb2729c5bbc Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Thu, 6 Aug 2026 16:55:28 +0800 Subject: [PATCH] fix(deploy): clean old hk test images before deploy Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- scripts/deploy-test-runtime.sh | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/scripts/deploy-test-runtime.sh b/scripts/deploy-test-runtime.sh index 645997b7..7358959d 100755 --- a/scripts/deploy-test-runtime.sh +++ b/scripts/deploy-test-runtime.sh @@ -191,6 +191,52 @@ normalize_base_path() { printf '%s' "${value}" } +cleanup_skillhub_test_space() { + echo "HK disk before SkillHub image cleanup:" >&2 + df -h /var/lib/docker /var/lib/containerd 2>/dev/null || df -h / >&2 + + docker container ls -aq \ + --filter "name=skillhub-runtime-" \ + --filter "status=exited" | + while read -r container_id; do + [[ -n "${container_id}" ]] || continue + docker container rm "${container_id}" >/dev/null 2>&1 || true + done + + running_image_ids="$( + docker ps --format '{{.Image}}' | + while read -r image_ref; do + [[ -n "${image_ref}" ]] || continue + docker image inspect --format '{{.Id}}' "${image_ref}" 2>/dev/null || true + done | + sort -u + )" + + docker image ls --format '{{.Repository}} {{.Tag}} {{.ID}}' | + while read -r repository tag image_id; do + case "${repository}" in + ghcr.io/iflytek/skillhub-server|ghcr.io/iflytek/skillhub-web|ghcr.io/iflytek/skillhub-scanner) ;; + *) continue ;; + esac + + case "${tag}" in + manual-test-hk*) ;; + *) continue ;; + esac + + if grep -Fxq "${image_id}" <<<"${running_image_ids}"; then + echo "Keeping running SkillHub image ${repository}:${tag}" >&2 + continue + fi + + echo "Removing old SkillHub test image ${repository}:${tag}" >&2 + docker image rm "${repository}:${tag}" >/dev/null 2>&1 || true + done + + echo "HK disk after SkillHub image cleanup:" >&2 + df -h /var/lib/docker /var/lib/containerd 2>/dev/null || df -h / >&2 +} + if [[ -n "${public_url}" ]]; then if [[ ! "${public_url}" =~ ^https?://[^[:space:]/?#]+(:[0-9]+)?(/[^[:space:]?#]*)?$ ]]; then echo "Invalid public URL: ${public_url}" >&2 @@ -203,6 +249,8 @@ if [[ -n "${web_base_path}" ]]; then normalized_web_base_path="$(normalize_base_path "${web_base_path}")" fi +cleanup_skillhub_test_space + helper_supports_sub_path=true if [[ -n "${public_url}" || -n "${web_base_path}" ]]; then helper_help="$(sudo /usr/local/bin/skillhub-test-deploy --help 2>&1 || true)"