#!/usr/bin/env bash
set -euo pipefail

echo "[host] cleanup v2 legacy containers/processes (best-effort)"

# Known historical container names from v1.1/v2 era
LEGACY=(
  mvp11-ray-head
  mvp11-ray-worker-0
  mvp11-ray-worker-1
  mvp2-ray-head
  mvp2-ray-worker-0
  mvp2-ray-worker-1
)

for c in "${LEGACY[@]}"; do
  if docker ps -a --format '{{.Names}}' | grep -qx "${c}"; then
    echo "[host] removing legacy container: ${c}"
    docker rm -f "${c}" >/dev/null 2>&1 || true
  fi
done

echo "[host] legacy v2 cleanup done"

