mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
image and video lanes: any loopback bind gets the filter, a bind past it hears about 30005, and a serving image lane restarts
One rule in lanes.sh (lane_ip_deny): 127.* and localhost are loopback, and a bind past it renders both filter lines empty. Its warning now says torch's port 30005 stays open on all the box's addresses. An update that changes the image lane's files restarts it while it serves (about 70 s, Hasan 2026-10-30): its filter comes in with the unit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ed85dce15
commit
85dc583ecb
9 files changed
+128
-59
No files matched your search
+18
-15
@@ -123,25 +123,24 @@ WHEEL="${SGLANG_DIFFUSION_WHEEL:-0.5.21}"
|
||||
# for someone who means to, and is told what it costs.
|
||||
IMAGE_BIND="${IMAGE_BIND:-$(unit_flag --host)}"; IMAGE_BIND="${IMAGE_BIND:-127.0.0.1}"
|
||||
case "$IMAGE_BIND" in
|
||||
127.0.0.1|localhost) ;;
|
||||
127.*|localhost) ;;
|
||||
*) echo "WARNING: binding $IMAGE_BIND. This lane has no API key (the diffusion runtime has"
|
||||
echo " no --api-key), so anyone who can reach that address can generate on your GPU."
|
||||
if [ "$IMAGE_BIND" = 0.0.0.0 ]; then
|
||||
echo " 0.0.0.0 is every interface: the LAN, the tailnet and any added later."
|
||||
fi
|
||||
echo " The scheduler's own channel stays on 127.0.0.1 whatever this bind (scheduler-loopback)."
|
||||
echo " torch's rendezvous port, 30005, listens on all the box's addresses too, with no key,"
|
||||
echo " and a bind past loopback leaves it unfiltered (SECURITY.md)."
|
||||
echo " Loopback plus the cockpit is the intended shape." ;;
|
||||
esac
|
||||
case "$IMAGE_BIND" in
|
||||
*[!0-9.]*|""|*..*) [ "$IMAGE_BIND" = localhost ] || die "IMAGE_BIND takes an IPv4 address, got: $IMAGE_BIND" ;;
|
||||
esac
|
||||
# The runtime listens past its bind: torch's TCPStore, the rendezvous of its one process group,
|
||||
# on port 30005 of every interface whatever address it is given, and gloo's and NCCL's bootstrap
|
||||
# on the box's own LAN address, four ports, none with a key (measured on the reference box,
|
||||
# 2026-10-30, its firewall off). The unit keeps that bootstrap on lo and, with a loopback bind,
|
||||
# lets the lane's processes talk to loopback alone (IPAddressDeny=any), which leaves the TCPStore
|
||||
# out of reach of any other machine. A bind past loopback serves others on purpose: no filter.
|
||||
case "$IMAGE_BIND" in 127.0.0.1|localhost) IMAGE_IP_DENY=any ;; *) IMAGE_IP_DENY="" ;; esac
|
||||
# The runtime listens past its bind: torch's TCPStore on port 30005 of every interface, and gloo's
|
||||
# and NCCL's bootstrap on the box's LAN address, none with a key (2026-10-30). The unit keeps that
|
||||
# bootstrap on lo, and a loopback bind gets its IP filter (lane_ip_deny, lanes.sh).
|
||||
IMAGE_IP_DENY="$(lane_ip_deny "$IMAGE_BIND")"; IMAGE_IP_ALLOW="${IMAGE_IP_DENY:+localhost}"
|
||||
WEIGHTS_GB=31; RUNTIME_GB=11 # the checkpoint; the venv, checkout and wheel (8.6 to 8.8) and the pip build tree
|
||||
|
||||
if [ "$ACTION" = uninstall ]; then
|
||||
@@ -205,7 +204,7 @@ install_service(){
|
||||
sed -e "s|__USER__|$(id -un)|g" -e "s|__GROUP__|$(id -gn "$(id -un)")|g" \
|
||||
-e "s|__IMAGE_LANE_DIR__|$LANE_DIR|g" -e "s|__IMAGE_VENV__|$VENV|g" \
|
||||
-e "s|__IMAGE_MODEL__|$MODEL|g" -e "s|__IMAGE_PORT__|$PORT|g" \
|
||||
-e "s|__IMAGE_BIND__|$IMAGE_BIND|g" -e "s|__IMAGE_IP_DENY__|$IMAGE_IP_DENY|g" -e "s|__HF_CACHE__|$HF_CACHE|g" \
|
||||
-e "s|__IMAGE_BIND__|$IMAGE_BIND|g" -e "s|__IMAGE_IP_DENY__|$IMAGE_IP_DENY|g" -e "s|__IMAGE_IP_ALLOW__|$IMAGE_IP_ALLOW|g" -e "s|__HF_CACHE__|$HF_CACHE|g" \
|
||||
-e "s|__HOME__|$HOME|g" \
|
||||
"$HERE/$UNIT.template" > "$RENDER"
|
||||
grep -q '__[A-Z][A-Z0-9_]*__' "$RENDER" && die "the unit template still holds an unsubstituted placeholder: $(grep -o '__[A-Z][A-Z0-9_]*__' "$RENDER" | sort -u | tr '\n' ' ')"
|
||||
@@ -231,14 +230,18 @@ install_service(){
|
||||
*) sudo systemctl daemon-reload
|
||||
echo "unit installed at $INSTALLED" ;;
|
||||
esac
|
||||
# A lane that serves goes on serving the unit, the runtime and the start scripts it started with:
|
||||
# said here when no proof follows to restart it, whether this run or an earlier update changed
|
||||
# them (an update leaves a serving lane serving, and said nothing for the image and video lanes:
|
||||
# found in review, 2026-10-14). The runtime's dates: runtime-changed, touched at each change
|
||||
# since v1.30, and the notes of the wheel, which said the changes before.
|
||||
# A lane that serves runs the unit, the runtime and the start scripts it started with, whether this run
|
||||
# or an earlier update changed them (said nothing for the image and video lanes until found in review,
|
||||
# 2026-10-14). The runtime's dates: runtime-changed, touched at each change since v1.30, and the notes
|
||||
# of the wheel, which said the changes before.
|
||||
LANE_FILES=("$INSTALLED" "$RUNTIME_NOTE" "$WHEEL_NOTE" "$CONFIG_DIR/engine-preflight.sh")
|
||||
# A serving image lane restarts to run them (Hasan, 2026-10-30, v1.40.6): about 70 s, and an image being made
|
||||
# then is lost. Its own sockets' filter came in with a unit, which a lane that kept serving never read. The
|
||||
# video lane, 12 to 15 min to boot, keeps its NOTE.
|
||||
if [ "$SMOKE" -eq 0 ] && lane_serves_older "$UNIT" "${LANE_FILES[@]}"; then
|
||||
echo "NOTE: The image lane runs older files than the ones installed now (its unit, its runtime or its start scripts); it runs these after: sudo systemctl restart $UNIT (or Load it again from the cockpit)"
|
||||
echo "the image lane serves older files than the ones installed now (its unit, its runtime or its start scripts): restarting it (about 70 s)"
|
||||
sudo systemctl restart "$UNIT" \
|
||||
|| echo "NOTE: the image lane did not restart; it runs the older files until: sudo systemctl restart $UNIT"
|
||||
fi
|
||||
# Installed, not switched to: the lane this box serves stays the lane it serves. The image
|
||||
# lane becomes the boot lane the same way the other two do, by a switch, which is also
|
||||
|
||||
+8
-9
@@ -130,23 +130,22 @@ WHEEL="${SGLANG_DIFFUSION_WHEEL:-0.5.21}"
|
||||
# VIDEO_BIND overrides it for someone who means to, and is told what it costs.
|
||||
VIDEO_BIND="${VIDEO_BIND:-$(unit_flag --host)}"; VIDEO_BIND="${VIDEO_BIND:-127.0.0.1}"
|
||||
case "$VIDEO_BIND" in
|
||||
127.0.0.1|localhost) ;;
|
||||
127.*|localhost) ;;
|
||||
0.0.0.0) die "VIDEO_BIND=0.0.0.0 puts a keyless video generator on EVERY interface (LAN, tailnet, future NICs). This lane has no --api-key; bind loopback (the cockpit is the door) or name one specific address." ;;
|
||||
*) echo "WARNING: binding $VIDEO_BIND. This lane has no API key (the diffusion runtime has"
|
||||
echo " no --api-key), so anyone who can reach that address can generate on your GPU."
|
||||
echo " The scheduler's own channel stays on 127.0.0.1 whatever this bind (scheduler-loopback)."
|
||||
echo " torch's rendezvous port, 30005, listens on all the box's addresses too, with no key,"
|
||||
echo " and a bind past loopback leaves it unfiltered (SECURITY.md)."
|
||||
echo " Loopback plus the cockpit is the intended shape." ;;
|
||||
esac
|
||||
case "$VIDEO_BIND" in
|
||||
*[!0-9.]*|""|*..*) [ "$VIDEO_BIND" = localhost ] || die "VIDEO_BIND takes an IPv4 address, got: $VIDEO_BIND" ;;
|
||||
esac
|
||||
# The runtime listens past its bind: torch's TCPStore, the rendezvous of its one process group,
|
||||
# on port 30005 of every interface whatever address it is given, and gloo's and NCCL's bootstrap
|
||||
# on the box's own LAN address, four ports, none with a key (measured on the reference box,
|
||||
# 2026-10-30, its firewall off). The unit keeps that bootstrap on lo and, with a loopback bind,
|
||||
# lets the lane's processes talk to loopback alone (IPAddressDeny=any), which leaves the TCPStore
|
||||
# out of reach of any other machine. A bind past loopback serves others on purpose: no filter.
|
||||
case "$VIDEO_BIND" in 127.0.0.1|localhost) VIDEO_IP_DENY=any ;; *) VIDEO_IP_DENY="" ;; esac
|
||||
# The runtime listens past its bind: torch's TCPStore on port 30005 of every interface, and gloo's
|
||||
# and NCCL's bootstrap on the box's LAN address, none with a key (2026-10-30). The unit keeps that
|
||||
# bootstrap on lo, and a loopback bind gets its IP filter (lane_ip_deny, lanes.sh).
|
||||
VIDEO_IP_DENY="$(lane_ip_deny "$VIDEO_BIND")"; VIDEO_IP_ALLOW="${VIDEO_IP_DENY:+localhost}"
|
||||
WEIGHTS_GB=135; RUNTIME_GB=11 # the fl2va partition plus the shared components and root
|
||||
# metadata, measured 2026-09-25: 144.1 GB cached in 88 files, which is 134.2 GiB, and the
|
||||
# room check below counts GiB (it said 145, and a box with the whole checkpoint cached was
|
||||
@@ -209,7 +208,7 @@ install_service(){
|
||||
-e "s|__VIDEO_LANE_DIR__|$LANE_DIR|g" -e "s|__VIDEO_VENV__|$VENV|g" \
|
||||
-e "s|__VIDEO_MODEL__|$MODEL|g" -e "s|__VIDEO_VARIANT__|$VARIANT|g" \
|
||||
-e "s|__VIDEO_PORT__|$PORT|g" \
|
||||
-e "s|__VIDEO_BIND__|$VIDEO_BIND|g" -e "s|__VIDEO_IP_DENY__|$VIDEO_IP_DENY|g" -e "s|__HF_CACHE__|$HF_CACHE|g" \
|
||||
-e "s|__VIDEO_BIND__|$VIDEO_BIND|g" -e "s|__VIDEO_IP_DENY__|$VIDEO_IP_DENY|g" -e "s|__VIDEO_IP_ALLOW__|$VIDEO_IP_ALLOW|g" -e "s|__HF_CACHE__|$HF_CACHE|g" \
|
||||
-e "s|__HOME__|$HOME|g" \
|
||||
"$HERE/$UNIT.template" > "$RENDER"
|
||||
grep -q '__[A-Z][A-Z0-9_]*__' "$RENDER" && die "the unit template still holds an unsubstituted placeholder: $(grep -o '__[A-Z][A-Z0-9_]*__' "$RENDER" | sort -u | tr '\n' ' ')"
|
||||
|
||||
@@ -773,3 +773,12 @@ PY
|
||||
return 0
|
||||
}
|
||||
forget_run_mark(){ [ -z "$RUN_MARK" ] || rm -f -- "$RUN_MARK"; return 0; }
|
||||
|
||||
# A diffusion lane's own sockets (v1.40.6): torch's TCPStore listens on every interface whatever its rendezvous
|
||||
# address (port 30005), and gloo's and NCCL's bootstrap took the box's LAN address until the unit pinned it to lo
|
||||
# (the reference box, 2026-10-30, no firewall). A bind on a loopback address, any 127.* or localhost, gets the unit's
|
||||
# IP filter, IPAddressDeny=any with IPAddressAllow=localhost: the lane talks to loopback alone. A bind past loopback
|
||||
# serves others on purpose and gets no filter. Printed: the deny list ("any"), or nothing.
|
||||
lane_ip_deny(){ # $1 the lane's bind
|
||||
case "$1" in 127.*|localhost) echo any ;; *) echo "" ;; esac
|
||||
}
|
||||
@@ -47,10 +47,10 @@ BindReadOnlyPaths=-__HOME__/.config/qwen38/engine-preflight.sh
|
||||
# shows to it until its next start.
|
||||
InaccessiblePaths=-/etc/qwen38
|
||||
# The runtime's own sockets (install-image.sh, IMAGE_IP_DENY): the bootstrap of its process group on lo
|
||||
# and, with a loopback bind, no traffic but loopback's.
|
||||
# and, with a loopback bind, no traffic but loopback's: no fetch of an image by its URL either.
|
||||
Environment=GLOO_SOCKET_IFNAME=lo
|
||||
Environment=NCCL_SOCKET_IFNAME=lo
|
||||
IPAddressAllow=localhost
|
||||
IPAddressAllow=__IMAGE_IP_ALLOW__
|
||||
IPAddressDeny=__IMAGE_IP_DENY__
|
||||
# The cookbook's DGX Spark recipe, and nothing else: one GPU, every component resident,
|
||||
# the runtime picking its own attention (it logs "Defaulting to Torch SDPA backend on
|
||||
|
||||
@@ -51,10 +51,10 @@ BindReadOnlyPaths=-__HOME__/.config/qwen38/engine-preflight.sh
|
||||
# shows to it until its next start.
|
||||
InaccessiblePaths=-/etc/qwen38
|
||||
# The runtime's own sockets (install-video.sh, VIDEO_IP_DENY): the bootstrap of its process group on lo
|
||||
# and, with a loopback bind, no traffic but loopback's.
|
||||
# and, with a loopback bind, no traffic but loopback's: no fetch of an image by its URL either.
|
||||
Environment=GLOO_SOCKET_IFNAME=lo
|
||||
Environment=NCCL_SOCKET_IFNAME=lo
|
||||
IPAddressAllow=localhost
|
||||
IPAddressAllow=__VIDEO_IP_ALLOW__
|
||||
IPAddressDeny=__VIDEO_IP_DENY__
|
||||
# The cookbook's DGX Spark recipe, and nothing else: every component resident, no
|
||||
# offload flags. The cookbook verifies about 12.1 s per denoise step, about 40 s of
|
||||
|
||||
@@ -60,6 +60,14 @@ def tier_args(tier, replay="1"):
|
||||
return r.stdout.strip()
|
||||
|
||||
|
||||
def ip_deny(bind):
|
||||
"""The diffusion units' deny list for this bind, by lanes.sh's own rule (lane_ip_deny), not a copy of it."""
|
||||
r = subprocess.run(["bash", "-c", f'. "{REPO}/lanes.sh"; lane_ip_deny "$1"', "_", bind],
|
||||
capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin"})
|
||||
assert r.returncode == 0, r.stderr
|
||||
return r.stdout.strip()
|
||||
|
||||
|
||||
def render(template, values):
|
||||
text = (REPO / template).read_text()
|
||||
for k, v in values.items():
|
||||
@@ -104,10 +112,10 @@ def box(context="1m", host="127.0.0.1", port="30000", hf=None, target27="RadixAr
|
||||
**common, "PORT": "30030", "GMU": "0.80", "IMAGE": "qwen38-kolibri:x", "MODEL": kolibri, "REV": "e" * 40}))
|
||||
lanes = f"{HOME}/.local/share"
|
||||
(units / "qwen38-image.service").write_text(render("qwen38-image.service.template", {
|
||||
**common, "IMAGE_BIND": host, "IMAGE_IP_DENY": "any" if host in ("127.0.0.1", "localhost") else "", "IMAGE_PORT": "30010", "IMAGE_LANE_DIR": f"{lanes}/qwen38-image",
|
||||
**common, "IMAGE_BIND": host, "IMAGE_IP_DENY": ip_deny(host), "IMAGE_IP_ALLOW": "localhost" if ip_deny(host) else "", "IMAGE_PORT": "30010", "IMAGE_LANE_DIR": f"{lanes}/qwen38-image",
|
||||
"IMAGE_VENV": f"{lanes}/qwen38-image/venv", "IMAGE_MODEL": image_model}))
|
||||
(units / "qwen38-video.service").write_text(render("qwen38-video.service.template", {
|
||||
**common, "VIDEO_BIND": host, "VIDEO_IP_DENY": "any" if host in ("127.0.0.1", "localhost") else "", "VIDEO_PORT": "30022", "VIDEO_LANE_DIR": f"{lanes}/qwen38-video",
|
||||
**common, "VIDEO_BIND": host, "VIDEO_IP_DENY": ip_deny(host), "VIDEO_IP_ALLOW": "localhost" if ip_deny(host) else "", "VIDEO_PORT": "30022", "VIDEO_LANE_DIR": f"{lanes}/qwen38-video",
|
||||
"VIDEO_VENV": f"{lanes}/qwen38-video/venv", "VIDEO_MODEL": "MiniMaxAI/MiniMax-H3",
|
||||
"VIDEO_VARIANT": video_variant}))
|
||||
if key_at is not None:
|
||||
|
||||
@@ -461,7 +461,8 @@ class TheLocalPatches(unittest.TestCase):
|
||||
"""The installer's own lines for the bind, run as they are written."""
|
||||
t = INSTALLER.read_text()
|
||||
block = t[t.index('IMAGE_BIND="${IMAGE_BIND:-$(unit_flag --host)}"'):t.index("WEIGHTS_GB=")]
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n' + block],
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n'
|
||||
f'. "{REPO}/lanes.sh"\n' + block],
|
||||
capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin", "IMAGE_BIND": value})
|
||||
return r.returncode, r.stdout + r.stderr
|
||||
|
||||
@@ -484,19 +485,41 @@ class TheLocalPatches(unittest.TestCase):
|
||||
def test_the_runtime_keeps_its_own_sockets_off_the_network(self):
|
||||
"""Whatever the bind, the runtime listened on *:30005 (torch's TCPStore) and on four ports
|
||||
of the box's LAN address (gloo's and NCCL's bootstrap), none with a key (the reference box,
|
||||
2026-10-30, its firewall off). The bootstrap goes on lo, and a loopback bind lets the lane's
|
||||
processes talk to loopback alone; a bind past loopback serves others on purpose."""
|
||||
2026-10-30, its firewall off). The bootstrap goes on lo, and a bind on any loopback address
|
||||
lets the lane's processes talk to loopback alone; a bind past loopback serves others on
|
||||
purpose, and its unit's two filter lines are written empty, which sets no filter."""
|
||||
service = UNIT_TPL.read_text().split("\n[Service]\n", 1)[1].split("\n[", 1)[0]
|
||||
for line in ("Environment=GLOO_SOCKET_IFNAME=lo", "Environment=NCCL_SOCKET_IFNAME=lo",
|
||||
"IPAddressAllow=localhost", "IPAddressDeny=__IMAGE_IP_DENY__"):
|
||||
"IPAddressAllow=__IMAGE_IP_ALLOW__", "IPAddressDeny=__IMAGE_IP_DENY__"):
|
||||
self.assertRegex(service, rf"(?m)^{re.escape(line)}$")
|
||||
t = INSTALLER.read_text()
|
||||
block = t[t.index('IMAGE_BIND="${IMAGE_BIND:-$(unit_flag --host)}"'):t.index("WEIGHTS_GB=")]
|
||||
for bind, deny in (("127.0.0.1", "any"), ("localhost", "any"), ("192.168.1.20", ""), ("0.0.0.0", "")):
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n' + block
|
||||
+ 'echo "deny=$IMAGE_IP_DENY"'], capture_output=True, text=True, timeout=30,
|
||||
env={"PATH": "/usr/bin:/bin", "IMAGE_BIND": bind})
|
||||
self.assertEqual((r.returncode, r.stdout.splitlines()[-1]), (0, f"deny={deny}"), bind)
|
||||
for bind, deny, allow in (("127.0.0.1", "any", "localhost"), ("localhost", "any", "localhost"),
|
||||
("127.0.0.2", "any", "localhost"), ("192.168.1.20", "", ""), ("0.0.0.0", "", "")):
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n'
|
||||
f'. "{REPO}/lanes.sh"\n' + block + 'echo "deny=$IMAGE_IP_DENY allow=$IMAGE_IP_ALLOW"'],
|
||||
capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin", "IMAGE_BIND": bind})
|
||||
self.assertEqual((r.returncode, r.stdout.splitlines()[-1]), (0, f"deny={deny} allow={allow}"), bind)
|
||||
# a bind past loopback is told what it leaves open
|
||||
rc, out = self._bind("192.168.1.20")
|
||||
self.assertIn("30005", out)
|
||||
|
||||
def test_an_update_restarts_a_serving_image_lane_that_runs_older_files(self):
|
||||
"""Hasan, 2026-10-30 (v1.40.6): its own sockets' filter comes in with a unit, which a lane that
|
||||
kept serving never read. About 70 s; the video lane, 12 to 15 min to boot, keeps its NOTE."""
|
||||
t = INSTALLER.read_text()
|
||||
start = t.index(' if [ "$SMOKE" -eq 0 ] && lane_serves_older "$UNIT" "${LANE_FILES[@]}"; then')
|
||||
block = t[start:t.index(" fi\n", start) + len(" fi\n")]
|
||||
for serves, want in ((0, "SUDO systemctl restart qwen38-image.service"), (1, None)):
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\nSMOKE=0; UNIT=qwen38-image.service; LANE_FILES=(a b)\n'
|
||||
f'lane_serves_older(){{ return {serves}; }}\nsudo(){{ echo "SUDO $*"; }}\n' + block],
|
||||
capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin"})
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
if want:
|
||||
self.assertIn(want, r.stdout)
|
||||
self.assertNotIn("NOTE:", r.stdout)
|
||||
else:
|
||||
self.assertEqual(r.stdout, "")
|
||||
|
||||
def test_the_installer_applies_exactly_the_patches_in_the_repo(self):
|
||||
listed = re.search(r"^PATCHES=\((.*)\)$", INSTALLER.read_text(), re.M).group(1).split()
|
||||
|
||||
@@ -11,6 +11,9 @@ installer said a restart was needed, and only for its own run's change (found in
|
||||
middleware, and the scripts every start runs first (the reviews of the fix, the same day). The installers' own lines run here, with a systemctl that answers when the lane started
|
||||
and files older or newer than that. The three vLLM lanes' installers (Kolibri, Nemotron Bolt and
|
||||
Super VL) run these lines from what they share, vllm-lane.sh, which is read here in their stead.
|
||||
An update that runs no proof restarts a serving image lane (about 70 s) since v1.40.6, as its filter
|
||||
of its own sockets came in with a unit a lane that kept serving never read: the video lane, 12 to
|
||||
15 min to boot, and the vLLM lanes keep the NOTE that says a restart is owed.
|
||||
"""
|
||||
import os
|
||||
import pathlib
|
||||
@@ -37,7 +40,7 @@ def blocks(script):
|
||||
# its lines are indented there, and read the same
|
||||
files = re.search(r'\n *LANE_FILES=\([^\n]*\)\n', text)
|
||||
note = re.search(r'\n( *)if \[ "\$SMOKE" -eq 0 \] && lane_serves_older "\$UNIT" "\$\{LANE_FILES\[@\]\}"; then\n'
|
||||
r'\1 echo "NOTE: [^\n]*\n\1fi\n', text)
|
||||
r'.*?\n\1fi\n', text, re.S)
|
||||
proof = re.search(r'\n( *)if \[ "\$%s" -eq 1 \] && lane_serves_older "\$UNIT" "\$\{LANE_FILES\[@\]\}"; then\n.*?\n\1fi\n'
|
||||
% LANES_OF[script], text, re.S)
|
||||
assert files and note and proof, f"{script}: its files, its note or its proof's start moved"
|
||||
@@ -45,7 +48,7 @@ def blocks(script):
|
||||
return files.group(0), note.group(0), proof.group(0)
|
||||
|
||||
|
||||
def run(script, block, serving, newer=(), was=1, smoke=1, restarts=None):
|
||||
def run(script, block, serving, newer=(), was=1, smoke=1, restarts=None, sudo_fails=False):
|
||||
"""`newer`: the files (FILES_OF's names, or "unit") changed after the lane started."""
|
||||
d = pathlib.Path(tempfile.mkdtemp(prefix="side-proof-"))
|
||||
started = int(time.time()) - 600
|
||||
@@ -68,7 +71,8 @@ def run(script, block, serving, newer=(), was=1, smoke=1, restarts=None):
|
||||
f'case "$*" in *ActiveState*) echo {"active" if serving else "inactive"};; '
|
||||
f'*ExecMainStartTimestamp*) echo "@{started}";; *NRestarts*) cat "{count}";; esac\n')
|
||||
# a start or a restart resets the count of automatic restarts, as systemd does
|
||||
(d / "sudo").write_text(f'#!/bin/bash\necho "sudo $*" >> "{log}"\necho 0 > "{count}"\n')
|
||||
(d / "sudo").write_text(f'#!/bin/bash\necho "sudo $*" >> "{log}"\n'
|
||||
+ ('exit 1\n' if sudo_fails else f'echo 0 > "{count}"\n'))
|
||||
for f in ("systemctl", "sudo"):
|
||||
(d / f).chmod(0o755)
|
||||
head = (f'set -euo pipefail\n. "{LANES}"\nUNIT=x.service; INSTALLED="{unit}"; '
|
||||
@@ -156,19 +160,38 @@ class TheVllmLanesCrashCountIsReadAfterItsStart(unittest.TestCase):
|
||||
|
||||
class AnUpdateSaysTheServingLaneNeedsARestart(unittest.TestCase):
|
||||
def test_said_when_no_proof_follows_and_something_is_newer_than_the_lane(self):
|
||||
for script in LANES_OF:
|
||||
for script in ("install-video.sh", "vllm-lane.sh"):
|
||||
note = blocks(script)[1]
|
||||
with self.subTest(script=script):
|
||||
out, _, _ = run(script, note, serving=True, newer=("unit",), smoke=0)
|
||||
out, calls, _ = run(script, note, serving=True, newer=("unit",), smoke=0)
|
||||
self.assertIn("runs older files than the ones installed now", out)
|
||||
self.assertEqual(calls, [], "said, not done")
|
||||
out, _, _ = run(script, note, serving=True, newer=(FILES_OF[script][0],), smoke=0)
|
||||
self.assertIn("runs older files than the ones installed now", out)
|
||||
out, _, _ = run(script, note, serving=True, smoke=0)
|
||||
self.assertEqual(out, "")
|
||||
out, _, _ = run(script, note, serving=False, newer=("unit",), was=0, smoke=0)
|
||||
self.assertEqual(out, "", "a lane that does not serve needs no restart")
|
||||
out, _, _ = run(script, note, serving=True, newer=("unit",), smoke=1)
|
||||
self.assertEqual(out, "", "the proof that follows restarts it")
|
||||
|
||||
def test_a_serving_image_lane_is_restarted_instead(self):
|
||||
script = "install-image.sh"
|
||||
update = blocks(script)[1]
|
||||
for newer in (("unit",), (FILES_OF[script][0],)):
|
||||
with self.subTest(newer=newer):
|
||||
out, calls, _ = run(script, update, serving=True, newer=newer, smoke=0)
|
||||
self.assertEqual(calls, ["sudo systemctl restart x.service"])
|
||||
self.assertIn("restarting it (about 70 s)", out)
|
||||
self.assertNotIn("NOTE", out)
|
||||
out, calls, _ = run(script, update, serving=True, newer=("unit",), smoke=0, sudo_fails=True)
|
||||
self.assertEqual(calls, ["sudo systemctl restart x.service"])
|
||||
self.assertIn("NOTE: the image lane did not restart", out, "a restart that failed is said")
|
||||
|
||||
def test_nothing_when_nothing_is_newer_the_lane_is_stopped_or_a_proof_follows(self):
|
||||
for script in LANES_OF:
|
||||
update = blocks(script)[1]
|
||||
with self.subTest(script=script):
|
||||
out, calls, _ = run(script, update, serving=True, smoke=0)
|
||||
self.assertEqual((out, calls), ("", []))
|
||||
out, calls, _ = run(script, update, serving=False, newer=("unit",), was=0, smoke=0)
|
||||
self.assertEqual((out, calls), ("", []), "a lane that does not serve needs no restart")
|
||||
out, calls, _ = run(script, update, serving=True, newer=("unit",), smoke=1)
|
||||
self.assertEqual((out, calls), ("", []), "the proof that follows restarts it")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -125,20 +125,24 @@ class TheUnit(unittest.TestCase):
|
||||
|
||||
def test_the_runtime_keeps_its_own_sockets_off_the_network(self):
|
||||
"""Whatever the bind, the installed lane listened on *:30005 (torch's TCPStore) and on four
|
||||
ports of the box's LAN address (gloo's and NCCL's bootstrap), none with a key (the
|
||||
reference box, 2026-10-30, its firewall off). The bootstrap goes on lo, and a loopback bind
|
||||
lets the lane's processes talk to loopback alone; a named address serves others on purpose."""
|
||||
ports of the box's LAN address (gloo's and NCCL's bootstrap), none with a key (the reference
|
||||
box, 2026-10-30, its firewall off). The bootstrap goes on lo, and a bind on any loopback
|
||||
address lets the lane's processes talk to loopback alone; a named address serves others on
|
||||
purpose, is told what that leaves open, and its unit's two filter lines are written empty,
|
||||
which sets no filter."""
|
||||
service = UNIT_TPL.read_text().split("\n[Service]\n", 1)[1].split("\n[", 1)[0]
|
||||
for line in ("Environment=GLOO_SOCKET_IFNAME=lo", "Environment=NCCL_SOCKET_IFNAME=lo",
|
||||
"IPAddressAllow=localhost", "IPAddressDeny=__VIDEO_IP_DENY__"):
|
||||
"IPAddressAllow=__VIDEO_IP_ALLOW__", "IPAddressDeny=__VIDEO_IP_DENY__"):
|
||||
self.assertRegex(service, rf"(?m)^{re.escape(line)}$")
|
||||
t = INSTALLER.read_text()
|
||||
block = t[t.index('VIDEO_BIND="${VIDEO_BIND:-$(unit_flag --host)}"'):t.index("WEIGHTS_GB=")]
|
||||
for bind, deny in (("127.0.0.1", "any"), ("localhost", "any"), ("192.168.1.20", "")):
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n' + block
|
||||
+ 'echo "deny=$VIDEO_IP_DENY"'], capture_output=True, text=True, timeout=30,
|
||||
env={"PATH": "/usr/bin:/bin", "VIDEO_BIND": bind})
|
||||
self.assertEqual((r.returncode, r.stdout.splitlines()[-1]), (0, f"deny={deny}"), bind)
|
||||
for bind, deny, allow, told in (("127.0.0.1", "any", "localhost", False), ("localhost", "any", "localhost", False),
|
||||
("127.0.0.2", "any", "localhost", False), ("192.168.1.20", "", "", True)):
|
||||
r = subprocess.run(["bash", "-c", 'set -euo pipefail\ndie(){ echo "DIE: $*"; exit 1; }\n'
|
||||
f'. "{REPO}/lanes.sh"\n' + block + 'echo "deny=$VIDEO_IP_DENY allow=$VIDEO_IP_ALLOW"'],
|
||||
capture_output=True, text=True, timeout=30, env={"PATH": "/usr/bin:/bin", "VIDEO_BIND": bind})
|
||||
self.assertEqual((r.returncode, r.stdout.splitlines()[-1]), (0, f"deny={deny} allow={allow}"), bind)
|
||||
self.assertEqual("30005" in r.stdout, told, bind)
|
||||
|
||||
def test_a_stop_is_a_ceiling_not_a_wait(self):
|
||||
"""A stop cancels the generation in under a second (measured on all seven
|
||||
|
||||
Reference in new issue
Block a user