Fix symnlinking of releases

This commit is contained in:
Audiobuzz
2026-06-28 01:50:33 +00:00
parent 02ffd7d885
commit 5e4ee87e88
2 changed files with 31 additions and 13 deletions
+19 -3
View File
@@ -102,6 +102,20 @@ cmd_add() {
[ -s "$dir/rootfs.erofs" ] || die "$dir/rootfs.erofs missing/empty"
[ -s "$dir/rootfs.hash" ] || die "$dir/rootfs.hash missing/empty"
# Guard: the dir name must match the version inside verity.json. A mismatch
# means a stale/symlinked or mislabeled release dir (e.g. an old symlink into
# the version-pinned /artifacts that now resolves to a different build) — that
# would serve the wrong data/NQN/UUIDs under this name. Refuse loudly. (Legacy
# artifacts have no image_version field — skip the check for them.)
# Case-insensitive: the dir name comes from the OCI tag while verity.json's
# image_version comes from the build var, which can differ only in case — a
# benign skew. A genuine mismatch (e.g. pxe-… vs spdk-…) differs by far more.
local vv
vv=$(vfield "$v" .image_version)
if [ -n "$vv" ] && [ "${vv,,}" != "${v,,}" ]; then
die "release dir '$v' holds verity.json for version '$vv' (stale symlink / mislabeled dir). Refusing to add — remove '$dir' and re-stage."
fi
local nqn du hu s
nqn=$(release_nqn "$v")
du=$(vfield "$v" .data_ns_uuid)
@@ -134,9 +148,11 @@ cmd_add() {
rpc nvmf_subsystem_add_ns "$nqn" "rootfs_$s" -u "$du"
rpc nvmf_subsystem_add_ns "$nqn" "roothash_$s" -u "$hu"
rpc nvmf_subsystem_add_listener "$nqn" -t tcp -a "$TADDR" -s "$TPORT"
# Register the listener on the discovery subsystem too (best-effort; older
# SPDK answers discovery implicitly but logs a deprecation warning).
rpc nvmf_subsystem_add_listener "$DISCOVERY_NQN" -t tcp -a "$TADDR" -s "$TPORT" 2>/dev/null || true
# Ensure the discovery subsystem has this listener too. The target already
# registered it at startup, so this is normally a no-op that SPDK reports as
# "Listener already exists" — fully suppress stdout+stderr (rpc.py prints the
# JSON error to STDOUT, so 2>/dev/null alone wouldn't hide it).
rpc nvmf_subsystem_add_listener "$DISCOVERY_NQN" -t tcp -a "$TADDR" -s "$TPORT" >/dev/null 2>&1 || true
echo "==> release $v ONLINE (existing connections untouched)"
}