diff --git a/scripts/README.md b/scripts/README.md index e0757b6..8e1ee4c 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -17,6 +17,7 @@ The workflows use a GitHub App token from the `sdk-bot` environment (secrets `SD | `update-drift-issue.sh [--dry-run]` | `core:drift-issue` | Create, update, or close the single `Core main drift` issue from a report. | | `report-failure.sh [--dry-run]` | `core:report-failure` | Append a dated failure line to the drift issue. Called from `if: failure()` steps. | | `drift-issue.sh` | | Shared helpers for the two drift issue scripts (sourced, not run). | +| `core-registry.sh` | | `core_registry `: the registry that holds a core release's images, `quay.io/ai-openshell` for releases since the move and `ghcr.io/nvidia/openshell` for older ones. Sourced by `open-bump-pr.sh` and `e2e/start-gateway.sh`. | | Workflow | Runs (mise tasks) | |----------|------| diff --git a/scripts/core-sync/core-registry.sh b/scripts/core-sync/core-registry.sh new file mode 100644 index 0000000..88b736c --- /dev/null +++ b/scripts/core-sync/core-registry.sh @@ -0,0 +1,21 @@ +# shellcheck shell=bash +# SPDX-License-Identifier: Apache-2.0 + +# core-registry.sh: sourced by e2e/start-gateway.sh and open-bump-pr.sh. +# +# core_registry prints the registry that holds the core gateway +# image (X.Y.Z or X.Y.Z-pre.N), or fails when neither has it yet. +# Releases since the move to Quay are on quay.io/ai-openshell; older ones stay +# on ghcr.io/nvidia/openshell for good. +core_registry() { + local accept='Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.oci.image.manifest.v1+json' + local token + if curl -fs -o /dev/null -H "$accept" "https://quay.io/v2/ai-openshell/gateway/manifests/$1"; then + echo quay.io/ai-openshell + return + fi + token=$(curl -fsS "https://ghcr.io/token?scope=repository:nvidia/openshell/gateway:pull" | jq -r .token) || return 1 + curl -fs -o /dev/null -H "Authorization: Bearer $token" -H "$accept" \ + "https://ghcr.io/v2/nvidia/openshell/gateway/manifests/$1" || return 1 + echo ghcr.io/nvidia/openshell +} diff --git a/scripts/core-sync/open-bump-pr.sh b/scripts/core-sync/open-bump-pr.sh index f73f183..4cdc4ab 100755 --- a/scripts/core-sync/open-bump-pr.sh +++ b/scripts/core-sync/open-bump-pr.sh @@ -25,7 +25,6 @@ set -euo pipefail core_repo=${CORE_REPO:-NVIDIA/OpenShell} sdk_repo=${SDK_REPO:-ai-openshell/sdk-python} -image=ghcr.io/nvidia/openshell/gateway diff_cap=400 tag= @@ -167,8 +166,12 @@ fi generated=$(git diff --stat "$base" "$branch" -- src/openshell/_proto | tail -1 | sed "s/^ *//") fixtures=$(cat "$work/fixtures.txt") +# shellcheck source=scripts/core-sync/core-registry.sh +. "$here/core-registry.sh" +# A fresh tag's images may not be pushed yet; new releases go to Quay. +registry=$(core_registry "${tag#v}") || registry=quay.io/ai-openshell body="$work/body.md" -OLD="$old" NEW="$tag" KIND="$kind" COMPARE_URL="$compare_url" IMAGE="$image:${tag#v}" \ +OLD="$old" NEW="$tag" KIND="$kind" COMPARE_URL="$compare_url" IMAGE="$registry/gateway:${tag#v}" \ GENERATED="${generated:-no generated files changed}" FIXTURES="${fixtures:- - none changed}" \ PROTO_DIFF="$proto_section" \ awk '{ diff --git a/scripts/e2e/start-gateway.sh b/scripts/e2e/start-gateway.sh index 0118e34..32d6b51 100755 --- a/scripts/e2e/start-gateway.sh +++ b/scripts/e2e/start-gateway.sh @@ -24,7 +24,6 @@ set -euo pipefail core_repo=${CORE_REPO:-NVIDIA/OpenShell} -registry=ghcr.io/nvidia/openshell name=e2e port=8080 health_port=8081 @@ -49,20 +48,15 @@ mkdir -p "$state" echo "$tag" >"$state/core-version" # Core pushes images after tagging; a proposal can be faster than that. -manifest_exists() { - local token - token=$(curl -fsS "https://ghcr.io/token?scope=repository:nvidia/openshell/gateway:pull" | jq -r .token) || return 1 - curl -fsS -o /dev/null -H "Authorization: Bearer $token" \ - -H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.oci.image.manifest.v1+json' \ - "https://ghcr.io/v2/nvidia/openshell/gateway/manifests/$semver" -} +# shellcheck source=scripts/core-sync/core-registry.sh +. "$(dirname "${BASH_SOURCE[0]}")/../core-sync/core-registry.sh" for i in $(seq 1 15); do - manifest_exists && break + registry=$(core_registry "$semver") && break if [ "$i" -eq 15 ]; then echo "ERROR: gateway image for $semver not published yet, re-run later" >&2 exit 1 fi - echo "Waiting for $registry/gateway:$semver ($i/15) ..." + echo "Waiting for the gateway image $semver ($i/15) ..." sleep 60 done @@ -70,6 +64,16 @@ done base="https://raw.githubusercontent.com/$core_repo/$tag/deploy/docker" curl -fsSL "$base/docker-compose.yml" -o "$state/docker-compose.yml" curl -fsSL "$base/gateway.toml" -o "$state/gateway.toml" +# Use the registry that holds this version: tags cut shortly after the move +# still name GHCR in their deployment files while their images are on Quay. +for f in docker-compose.yml gateway.toml; do + sed -E -i.bak "s#(ghcr\.io/nvidia/openshell|quay\.io/ai-openshell)/#$registry/#g" "$state/$f" && + rm -f "$state/$f.bak" +done +grep -q "$registry/gateway:" "$state/docker-compose.yml" || { + echo "ERROR: core's docker-compose.yml at $tag does not use $registry/gateway" >&2 + exit 1 +} sed -i.bak \ -e "s#\"$registry/supervisor:latest\"#\"$registry/supervisor:$semver\"#" \ -e "s#\"$registry/sandbox:latest\"#\"$registry/sandbox:$semver\"#" \