Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

fix(cli): ods update --dry-run lists what the update pulls (#8274)

Mike Bradleybeb8e4b9cc58
diff --git a/ods/ods-cli b/ods/ods-cli
index 0312eae8b..88ad79bdf 100755
--- a/ods/ods-cli
+++ b/ods/ods-cli
@@ -2323,10 +2323,27 @@ cmd_dry_run() {
local -a flags
read -ra flags <<< "$flags_str"
- # Prefer API response; fall back to parsing compose files directly.
+ # List what `ods update` pulls: its own discovery over this install's
+ # resolved stack (see _ods_cli_pull_external_images). The API can only read
+ # every compose file's image lines, unresolved and for every GPU backend,
+ # so its list is the fallback.
+ local images_shown=false image_output=""
+ local helper="$INSTALL_DIR/installers/lib/compose-images.sh"
+ if ! command -v ods_compose_external_images >/dev/null 2>&1 && [[ -f "$helper" ]]; then
+ . "$helper"
+ fi
+ if command -v ods_compose_external_images >/dev/null 2>&1 \
+ && image_output="$(ods_compose_external_images "docker compose" "${flags[@]}")"; then
+ local _img_line
+ while IFS= read -r _img_line; do
+ [[ -n "$_img_line" ]] && echo " ${_img_line}"
+ done <<< "$image_output"
+ [[ -n "$image_output" ]] || echo " (none: every service image is built locally)"
+ images_shown=true
+ fi
# Use process substitution so flags like images_shown update in this shell (not a pipe subshell).
- local images_shown=false
- if [[ -n "$api_json" ]] && echo "$api_json" | jq -e '.images | length > 0' >/dev/null 2>&1; then
+ if [[ "$images_shown" == "false" ]] && [[ -n "$api_json" ]] \
+ && echo "$api_json" | jq -e '.images | length > 0' >/dev/null 2>&1; then
local _img_line _any_api=false
while IFS= read -r _img_line || [[ -n "$_img_line" ]]; do
[[ -z "$_img_line" ]] && continue
@@ -2335,23 +2352,23 @@ cmd_dry_run() {
done < <(echo "$api_json" | jq -r '.images[]' | sort -u)
[[ "$_any_api" == "true" ]] && images_shown=true
fi
- if [[ "$images_shown" == "false" ]]; then
- local _img_line _any_compose=false
- while IFS= read -r _img_line || [[ -n "$_img_line" ]]; do
- [[ -z "$_img_line" ]] && continue
- echo " ${_img_line}"
- _any_compose=true
- done < <(docker compose "${flags[@]}" config 2>/dev/null \
- | grep -E '^\s+image:' | sed 's/.*image:\s*//' | sort -u)
- [[ "$_any_compose" == "true" ]] && images_shown=true
- fi
[[ "$images_shown" == "false" ]] && echo " (could not resolve compose config)"
echo ""
echo -e "${BLUE}━━━ Running image digests ━━━${NC}"
- docker compose "${flags[@]}" images 2>/dev/null \
- | awk 'NR>1 {printf " %-30s %s\n", $1, $4}' \
- || echo " (services not running)"
+ # Read each running container's image ID. `docker compose images` moved
+ # that column when it added PLATFORM, so this section printed platforms.
+ # A preview that cannot list the stack reports it as not running.
+ local running_ids=""
+ running_ids=$(docker compose "${flags[@]}" ps -q 2>/dev/null || true)
+ if [[ -n "$running_ids" ]]; then
+ # shellcheck disable=SC2086 # one container ID per word
+ docker inspect --format '{{.Name}} {{.Image}}' $running_ids 2>/dev/null \
+ | awk '{sub(/^\//, "", $1); sub(/^sha256:/, "", $2); printf " %-30s %s\n", $1, substr($2, 1, 12)}' \
+ || echo " (could not read the running containers)"
+ else
+ echo " (services not running)"
+ fi
echo ""
# ── model / GGUF ─────────────────────────────────────────────────────────
diff --git a/ods/tests/ci-suite.txt b/ods/tests/ci-suite.txt
index 9b5398440..6c1b964fa 100644
--- a/ods/tests/ci-suite.txt
+++ b/ods/tests/ci-suite.txt
@@ -323,6 +323,7 @@ tests/test-backup-publication.sh
tests/test-restore-compose-flags.sh
tests/test-cli-purge-docker-inspection.sh
tests/test-ods-cli-update-backup-required.sh
+tests/test-ods-cli-dry-run-images.sh
tests/test-update-backup-publication.py
tests/test-update-changelog-fallback.py
tests/test-gpu-reassign-preflight.sh
diff --git a/ods/tests/test-ods-cli-dry-run-images.sh b/ods/tests/test-ods-cli-dry-run-images.sh
new file mode 100644
index 000000000..f8eaca0aa
--- /dev/null
+++ b/ods/tests/test-ods-cli-dry-run-images.sh
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+# `ods update --dry-run` lists the images `ods update` would pull and the
+# image IDs of the running containers.
+set -euo pipefail
+
+root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+tmp="$(mktemp -d)"
+trap 'rm -rf -- "$tmp"' EXIT
+PASS=0
+FAIL=0
+
+install="$tmp/install"
+bin="$tmp/bin"
+mkdir -p "$install/installers/lib" "$bin" "$tmp/home"
+cp "$root_dir/docker-compose.base.yml" "$root_dir/manifest.json" "$install/"
+cp "$root_dir/installers/lib/compose-images.sh" "$install/installers/lib/"
+printf '%s\n' '-f docker-compose.base.yml' > "$install/.compose-flags"
+cat > "$install/.env" <<'ENV'
+ODS_VERSION=3.0.0
+ODS_MODE=local
+GPU_BACKEND=nvidia
+GPU_COUNT=2
+TIER=4
+DASHBOARD_API_KEY=test-key
+ENV
+
+# Workstation06 (2026-10-27): the preview printed the API's list, which named
+# every backend's images as raw ${VAR:-default} strings, and its digest column
+# printed linux/arm64.
+cat > "$bin/curl" <<'CURL'
+#!/usr/bin/env bash
+case "$*" in
+ *api/update/dry-run*)
+ printf '%s\n' '{"current_version":"3.0.0","latest_version":"3.0.0","update_available":false,"images":["${LLAMA_ARC_IMAGE:-ods-llama-sycl:local}","ghcr.io/ggml-org/llama.cpp:server-rocm-b9014"],"env_keys":{}}'
+ ;;
+ *) exit 7 ;;
+esac
+CURL
+cat > "$bin/docker" <<'DOCKER'
+#!/usr/bin/env bash
+case " $* " in
+ *' config --format json '*)
+ printf '%s\n' '{"services":{"dashboard":{"image":"ods-dashboard:local"},"dashboard-api":{"build":{"context":"."},"image":"registry.example/dashboard-api:dev"},"llama-server":{"image":"ghcr.io/ggml-org/llama.cpp:server-cuda-b11429@sha256:aaaa"},"open-webui":{"image":"ghcr.io/open-webui/open-webui:v0.11.4@sha256:bbbb"}}}'
+ ;;
+ *' ps -q '*) printf 'c1\nc2\n' ;;
+ *' inspect '*) printf '/ods-llama-server sha256:0123456789abcdef0000\n/ods-open-webui sha256:fedcba9876543210ffff\n' ;;
+ *' images '*) printf 'CONTAINER REPOSITORY TAG PLATFORM IMAGE ID SIZE\nods-llama-server x y linux/arm64 0123 1GB\n' ;;
+esac
+exit 0
+DOCKER
+# Guard every host mutator; a preview must not need one.
+for mutator in systemctl sudo pkill killall service launchctl; do
+ printf '#!/bin/sh\nexit 97\n' > "$bin/$mutator"
+done
+chmod +x "$bin"/*
+
+out=$(PATH="$bin:$PATH" HOME="$tmp/home" INSTALL_DIR="$install" ODS_HOME="$install" NO_COLOR=1 \
+ bash "$root_dir/ods-cli" update --dry-run 2>&1)
+
+images=$(sed -n '/Image tags (would be pulled)/,/Running image digests/p' <<< "$out")
+digests=$(sed -n '/Running image digests/,/Model configuration/p' <<< "$out")
+
+check() {
+ local label="$1"
+ shift
+ if "$@"; then
+ echo " PASS: $label"
+ PASS=$((PASS + 1))
+ else
+ echo " FAIL: $label"
+ FAIL=$((FAIL + 1))
+ fi
+}
+has() { [[ "$1" == *"$2"* ]]; }
+lacks() { [[ "$1" != *"$2"* ]]; }
+matches() { [[ "$1" =~ $2 ]]; }
+
+echo "=== ods update --dry-run lists what the update pulls ==="
+check "lists the resolved llama-server image" has "$images" "ghcr.io/ggml-org/llama.cpp:server-cuda-b11429@sha256:aaaa"
+check "lists the resolved Open WebUI image" has "$images" "ghcr.io/open-webui/open-webui:v0.11.4@sha256:bbbb"
+check "skips local build tags" lacks "$images" "ods-dashboard:local"
+check "skips services built from source" lacks "$images" "registry.example/dashboard-api"
+check "does not print the API's unresolved list" lacks "$images" "LLAMA_ARC_IMAGE"
+check "does not print other backends' images" lacks "$images" "server-rocm"
+check "prints each running container's image ID" matches "$digests" "ods-llama-server[[:space:]]+0123456789ab"
+check "does not print platforms as digests" lacks "$digests" "linux/arm64"
+
+echo ""
+echo "Passed: $PASS Failed: $FAIL"
+if (( FAIL > 0 )); then
+ printf '%s\n' "$out"
+ exit 1
+fi