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(installer): persist the installer tier as TIER in .env (#8150)

Satyam Singh6a515b722bb5
diff --git a/ods/installers/macos/lib/env-generator.sh b/ods/installers/macos/lib/env-generator.sh
index b26df52c4..200149a0a 100755
--- a/ods/installers/macos/lib/env-generator.sh
+++ b/ods/installers/macos/lib/env-generator.sh
@@ -609,6 +609,7 @@ ODS_MACOS_HOST_AGENT_BRIDGE_ENABLED=${macos_host_agent_bridge_enabled}
ODS_MACOS_HOST_GATEWAY=${macos_host_gateway}
ODS_MACOS_VM_IP=${macos_vm_ip}
ODS_NATIVE_LLAMA_PORT=${native_llama_port}
+TIER=${tier}
MODEL_PROFILE=${MODEL_PROFILE_REQUESTED:-${MODEL_PROFILE:-qwen}}
# Effective model profile for this hardware: ${MODEL_PROFILE_EFFECTIVE:-qwen}
LLM_MODEL=${LLM_MODEL}
diff --git a/ods/installers/phases/06-directories.sh b/ods/installers/phases/06-directories.sh
index 2f795e653..0ec6691ac 100755
--- a/ods/installers/phases/06-directories.sh
+++ b/ods/installers/phases/06-directories.sh
@@ -1648,6 +1648,9 @@ MINIMAX_API_KEY=$(dotenv_value "${MINIMAX_API_KEY:-}")
TARGET_API_KEY=not-needed
#=== LLM Settings (llama-server) ===
+# Read back by ods-cli (status-json, mode, model current), the host agent and
+# bootstrap-upgrade when they re-resolve the compose stack.
+TIER=$(dotenv_value "${TIER}")
MODEL_PROFILE=$(dotenv_value "${MODEL_PROFILE_VALUE}")
# Effective model profile for this hardware: ${MODEL_PROFILE_EFFECTIVE:-qwen}
LLM_MODEL=${LLM_MODEL}
diff --git a/ods/installers/windows/lib/env-generator.ps1 b/ods/installers/windows/lib/env-generator.ps1
index 182f4f80c..6d0238e30 100644
--- a/ods/installers/windows/lib/env-generator.ps1
+++ b/ods/installers/windows/lib/env-generator.ps1
@@ -749,6 +749,7 @@ TOGETHER_API_KEY=$(Get-EnvOrNew "TOGETHER_API_KEY" "")
MINIMAX_API_KEY=$(Get-EnvOrNew "MINIMAX_API_KEY" "")
#=== LLM Settings (llama-server) ===
+TIER=$Tier
MODEL_PROFILE=$(Get-EnvOrNew "MODEL_PROFILE" "$(if ($TierConfig.ModelProfileRequested) { $TierConfig.ModelProfileRequested } else { "qwen" })")
LLM_MODEL=$($TierConfig.LlmModel)
GGUF_FILE=$($TierConfig.GgufFile)
diff --git a/ods/tests/ci-suite.txt b/ods/tests/ci-suite.txt
index d57cfcce7..41505c2e0 100644
--- a/ods/tests/ci-suite.txt
+++ b/ods/tests/ci-suite.txt
@@ -187,6 +187,7 @@ tests/test-phase05-docker-desktop-nvidia-refusal.sh
tests/test-phase05-podman-shim.sh
tests/test-phase06-hermes-owner-card-rerun.sh
tests/test-phase06-secret-generation.sh
+tests/test-phase06-tier-persisted.sh
tests/test_searxng_source_copy_preservation.py
tests/test-phase08-selected-images.sh
tests/test-phase10-skip-templated-user-units.sh
diff --git a/ods/tests/test-macos-env-schema.sh b/ods/tests/test-macos-env-schema.sh
index 086dea9b7..f1d4c6c08 100755
--- a/ods/tests/test-macos-env-schema.sh
+++ b/ods/tests/test-macos-env-schema.sh
@@ -98,6 +98,8 @@ for tier in 1 CLOUD; do
|| fail "tier $tier macOS install must bound Kokoro threads"
grep -qx 'HERMES_REQUIRE_OWNER_CARD=false' "$env_file" \
|| fail "tier $tier must open Hermes without an owner card by default"
+ grep -qx "TIER=$tier" "$env_file" \
+ || fail "tier $tier .env must persist TIER for ods-cli and the host agent"
pass "tier $tier: generated .env assigns every key once"
# validate-env.sh needs Bash 4+ (associative arrays); ods-cli runs it with
diff --git a/ods/tests/test-phase06-tier-persisted.sh b/ods/tests/test-phase06-tier-persisted.sh
new file mode 100755
index 000000000..2ca14338d
--- /dev/null
+++ b/ods/tests/test-phase06-tier-persisted.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Phase 06 must write the installer tier to .env as TIER. ods-cli
+# (enable/disable), the host agent and ods-update read it back and pass it to
+# resolve-compose-stack.sh; without it they resolve tier 1 and drop the tier 0
+# memory overlay (docker-compose.tier0.yml) that the installer applied.
+# Renders phase 06's shipped template line, loads the result the way ods-cli
+# does, and runs the real resolver with that tier.
+set -euo pipefail
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+PHASE="$ROOT_DIR/installers/phases/06-directories.sh"
+# shellcheck source=../lib/safe-env.sh
+. "$ROOT_DIR/lib/safe-env.sh"
+# shellcheck source=../lib/dotenv-quote.sh
+. "$ROOT_DIR/lib/dotenv-quote.sh"
+
+PASS=0
+FAIL=0
+pass() { PASS=$((PASS + 1)); printf '[PASS] %s\n' "$1"; }
+fail() { FAIL=$((FAIL + 1)); printf '[FAIL] %s\n' "$1" >&2; }
+
+tmp_dir="$(mktemp -d)"
+trap 'rm -rf "$tmp_dir"' EXIT
+
+template="$(awk '
+ /cat > "\$INSTALL_DIR\/.env" << ENV_EOF/ { body = 1; next }
+ body && $0 == "ENV_EOF" { exit }
+ body && /^TIER=/ { print }
+' "$PHASE")"
+[[ -n "$template" ]] || { fail "phase 06 does not write TIER to .env"; printf '\nResult: %d passed, %d failed\n' "$PASS" "$FAIL"; exit 1; }
+
+# Usage: resolved_overlays INSTALLER_TIER -> the compose files ods-cli would resolve
+resolved_overlays() {
+ (
+ TIER="$1"
+ eval "printf '%s\n' \"$template\"" > "$tmp_dir/.env"
+ unset TIER
+ load_env_file "$tmp_dir/.env"
+ bash "$ROOT_DIR/scripts/resolve-compose-stack.sh" --script-dir "$ROOT_DIR" \
+ --tier "${TIER:-1}" --gpu-backend cpu
+ )
+}
+
+for tier in 0 T0; do
+ overlays="$(resolved_overlays "$tier")"
+ [[ "$overlays" == *docker-compose.tier0.yml* ]] \
+ && pass "tier $tier keeps the tier 0 memory overlay after .env is read back" \
+ || fail "tier $tier lost docker-compose.tier0.yml: $overlays"
+done
+
+overlays="$(resolved_overlays 2)"
+[[ "$overlays" != *docker-compose.tier0.yml* ]] \
+ && pass "tier 2 does not get the tier 0 memory overlay" \
+ || fail "tier 2 resolved docker-compose.tier0.yml: $overlays"
+
+TIER=SH_LARGE
+[[ "$(eval "printf '%s\n' \"$template\"")" == "TIER=SH_LARGE" ]] \
+ && pass "named tiers are written unquoted" \
+ || fail "named tier rendered as: $(eval "printf '%s\n' \"$template\"")"
+
+printf '\nResult: %d passed, %d failed\n' "$PASS" "$FAIL"
+[[ "$FAIL" -eq 0 ]]
diff --git a/ods/tests/test-windows-llama-memory-budget.ps1 b/ods/tests/test-windows-llama-memory-budget.ps1
index 190de05c2..a9a56e612 100644
--- a/ods/tests/test-windows-llama-memory-budget.ps1
+++ b/ods/tests/test-windows-llama-memory-budget.ps1
@@ -52,6 +52,10 @@ try {
if ($nvidiaEnv -notmatch '(?m)^TTS_WORKERS=1\r?$' -or $nvidiaEnv -notmatch '(?m)^TTS_THREADS=4\r?$') {
throw "Fresh Windows install did not give one Kokoro worker a bounded four-thread budget"
}
+ # `ods model current` and the host agent read the tier back from .env.
+ if ($nvidiaEnv -notmatch '(?m)^TIER=1\r?$') {
+ throw "Generated .env does not persist TIER"
+ }
$nvidiaEnv = $nvidiaEnv -replace '(?m)^LLAMA_SERVER_MEMORY_LIMIT=.*$', 'LLAMA_SERVER_MEMORY_LIMIT=7G'
$nvidiaEnv = $nvidiaEnv -replace '(?m)^TTS_WORKERS=.*$', "TTS_WORKERS='2'"