diff --git a/scripts/ci/amd/amd_ci_start_container.sh b/scripts/ci/amd/amd_ci_start_container.sh index d8b6fd020..81a70421f 100755 --- a/scripts/ci/amd/amd_ci_start_container.sh +++ b/scripts/ci/amd/amd_ci_start_container.sh @@ -173,11 +173,17 @@ find_latest_image() { fi done - # If still not found, try finding any image matching ROCm+arch from remote registry - echo "Exact version not found. Searching remote registry for any ${ROCM_VERSION}-${gpu_arch} image…" >&2 + # Docker Hub's `name=` filter is fuzzy; only accept official version tags. + echo "Exact version not found. Searching remote registry for versioned ${ROCM_VERSION}-${gpu_arch} images…" >&2 for days_back in {0..6}; do local target_date=$(date -d "${days_back} days ago" +%Y%m%d) - remote_tags=$(curl -s "https://registry.hub.docker.com/v2/repositories/rocm/sgl-dev/tags?page_size=100&name=${ROCM_VERSION}-${gpu_arch}-${target_date}" 2>/dev/null | grep -o '"name":"[^"]*"' | cut -d'"' -f4 | head -n 1 || true) + local sgl_tag_regex="^v[0-9][A-Za-z0-9._-]*-${ROCM_VERSION}-${gpu_arch}-${target_date}$" + remote_tags=$(curl -s "https://registry.hub.docker.com/v2/repositories/rocm/sgl-dev/tags?page_size=100&name=${ROCM_VERSION}-${gpu_arch}-${target_date}" 2>/dev/null | grep -o '"name":"[^"]*"' | cut -d'"' -f4 | while read -r tag; do + if [[ "${tag}" =~ ${sgl_tag_regex} ]]; then + echo "${tag}" + break + fi + done || true) if [[ -n "$remote_tags" ]]; then echo "Found available image: rocm/sgl-dev:${remote_tags}" >&2 echo "rocm/sgl-dev:${remote_tags}" @@ -185,9 +191,14 @@ find_latest_image() { fi done - echo "No recent images found. Searching any cached local images matching ROCm+arch…" >&2 + echo "No recent images found. Searching cached local versioned images matching ROCm+arch…" >&2 local any_local - any_local=$(docker images --format '{{.Repository}}:{{.Tag}}' --filter "reference=rocm/sgl-dev:*${ROCM_VERSION}*${gpu_arch}*" | sort -r | head -n 1) + any_local=$(docker images --format '{{.Repository}}:{{.Tag}}' --filter "reference=rocm/sgl-dev:v*-${ROCM_VERSION}-${gpu_arch}-*" | while read -r image; do + local tag="${image#rocm/sgl-dev:}" + if [[ "${tag}" =~ ^v[0-9][A-Za-z0-9._-]*-${ROCM_VERSION}-${gpu_arch}-[0-9]{8}$ ]]; then + echo "${image}" + fi + done | sort -r | head -n 1) if [[ -n "$any_local" ]]; then echo "Using cached fallback image: ${any_local}" >&2 echo "${any_local}" diff --git a/scripts/ci/amd/amd_ci_start_container_disagg.sh b/scripts/ci/amd/amd_ci_start_container_disagg.sh index 0095b68ed..e04d6575e 100755 --- a/scripts/ci/amd/amd_ci_start_container_disagg.sh +++ b/scripts/ci/amd/amd_ci_start_container_disagg.sh @@ -156,11 +156,17 @@ find_latest_image() { fi done - # If still not found, try finding any image matching ROCm+arch from remote registry - echo "Exact version not found. Searching remote registry for any ${ROCM_VERSION}-${gpu_arch} image…" >&2 + # Docker Hub's `name=` filter is fuzzy; only accept official version tags. + echo "Exact version not found. Searching remote registry for versioned ${ROCM_VERSION}-${gpu_arch} images…" >&2 for days_back in {0..6}; do local target_date=$(date -d "${days_back} days ago" +%Y%m%d) - remote_tags=$(curl -s "https://registry.hub.docker.com/v2/repositories/rocm/sgl-dev/tags?page_size=100&name=${ROCM_VERSION}-${gpu_arch}-${target_date}" 2>/dev/null | grep -o '"name":"[^"]*"' | cut -d'"' -f4 | head -n 1 || true) + local sgl_tag_regex="^v[0-9][A-Za-z0-9._-]*-${ROCM_VERSION}-${gpu_arch}-${target_date}$" + remote_tags=$(curl -s "https://registry.hub.docker.com/v2/repositories/rocm/sgl-dev/tags?page_size=100&name=${ROCM_VERSION}-${gpu_arch}-${target_date}" 2>/dev/null | grep -o '"name":"[^"]*"' | cut -d'"' -f4 | while read -r tag; do + if [[ "${tag}" =~ ${sgl_tag_regex} ]]; then + echo "${tag}" + break + fi + done || true) if [[ -n "$remote_tags" ]]; then echo "Found available image: rocm/sgl-dev:${remote_tags}" >&2 echo "rocm/sgl-dev:${remote_tags}" @@ -168,9 +174,14 @@ find_latest_image() { fi done - echo "No recent images found. Searching any cached local images matching ROCm+arch…" >&2 + echo "No recent images found. Searching cached local versioned images matching ROCm+arch…" >&2 local any_local - any_local=$(docker images --format '{{.Repository}}:{{.Tag}}' --filter "reference=rocm/sgl-dev:*${ROCM_VERSION}*${gpu_arch}*" | sort -r | head -n 1) + any_local=$(docker images --format '{{.Repository}}:{{.Tag}}' --filter "reference=rocm/sgl-dev:v*-${ROCM_VERSION}-${gpu_arch}-*" | while read -r image; do + local tag="${image#rocm/sgl-dev:}" + if [[ "${tag}" =~ ^v[0-9][A-Za-z0-9._-]*-${ROCM_VERSION}-${gpu_arch}-[0-9]{8}$ ]]; then + echo "${image}" + fi + done | sort -r | head -n 1) if [[ -n "$any_local" ]]; then echo "Using cached fallback image: ${any_local}" >&2 echo "${any_local}"