ci(runner): drain legacy docker act runner safely
All checks were successful
Code Review / ai-code-review (push) Successful in 11s

This commit is contained in:
Your Name
2026-05-21 18:53:45 +08:00
parent 19739339e7
commit 9b465ee140
4 changed files with 77 additions and 7 deletions

View File

@@ -37,6 +37,17 @@ cleanup_artifacts() {
rm -rf node_modules apps/web/node_modules 2>/dev/null || true
}
cleanup_empty_docker_network() {
local network="$1"
local containers_json
command -v docker >/dev/null 2>&1 || return 0
containers_json="$(docker network inspect "$network" --format '{{json .Containers}}' 2>/dev/null || true)"
[ "$containers_json" = "{}" ] || return 0
docker network rm "$network" >/dev/null 2>&1 || true
}
has_leftovers() {
local root="$1"
[ -d "$root/.pytest_cache" ] && return 0
@@ -53,6 +64,7 @@ has_leftovers() {
}
cleanup_artifacts "$ROOT"
cleanup_empty_docker_network "b5-test-net"
if has_leftovers "$ROOT" && [ -n "$CLEANUP_IMAGE" ] && command -v docker >/dev/null 2>&1; then
echo "host cleanup left root-owned artifacts; retrying through ${CLEANUP_IMAGE}"

View File

@@ -228,8 +228,15 @@ PY
fi
# 已停用 Docker-wrapped runner避免它搶走 host label job。
# 若手動執行此 recovery script 時仍有 task container送 SIGINT
# 讓 act_runner drain不再接新 job並等手上的 job 收尾。
docker update --restart=no gitea-runner >/dev/null 2>&1 || true
docker stop gitea-runner >/dev/null 2>&1 || true
if docker ps --format '{{.Names}}' | grep -q '^GITEA-ACTIONS-TASK-'; then
log "⚠️ Gitea Actions task container still running; draining docker-wrapped gitea-runner"
docker kill --signal=SIGINT gitea-runner >/dev/null 2>&1 || true
else
docker stop -t 3700 gitea-runner >/dev/null 2>&1 || true
fi
sleep 15