installer 1.38.0 on main (NOT tagged): an appliance install stops on a system disk below 200 GB; --accept-small-disk for the operator (D83, R-1370); R-1398 filed

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 14:32:13 +01:00
1 parent 44715fb38b
commit 92853bed2c
6 files changed
+370 -5

No files matched your search

+18
View File
@@ -1,3 +1,21 @@
## Unreleased (2026-11-15) — felhom-host-install.sh v1.38.0 on `main`, NOT tagged, so NOT published: an appliance install stops on a system disk below 200 GB (D83, R-1370)
- **`check_system_disk`, first thing in the preflight, before anything is changed** (`09` §3 decision 308; design
`16-storage-physical-identity.md` §14.5). The system disk is the ONE whole disk under the `pve` volume group
(`pvs`, `lsblk`); its size is the kernel's sector count (`/sys/block/<disk>/size` × 512). Below 200 × 10⁹ bytes an
appliance install stops: „This machine's system disk is 128 GB. Felhom needs 200 GB. Nothing was changed.” A size
that cannot be read (no `pve` group, two physical volumes, a RAID, no size) stops too and names the flag.
- **`--accept-small-disk` (operator only):** goes on, prints the cost, records `small_disk: true` and
`system_disk_bytes` in the install state, and adds `"small_disk":true` to the enrolment request. **The hub does not
read that field yet** (R-1398).
- **A byo host is warned only**, with or without a readable size; so is a `--preflight-only` run with no `--mode`.
- The 120 GiB pool warning stays as the second check.
- **Known gap, R-1398:** on the public image the first-boot unit runs the installer again until it succeeds, so a
refused machine prints the refusal on its screen every 30 seconds and the hub is not told why.
- `test_hostinstall.py`: eight tests, one per row of the design's table that can be tested, with stubs for `pvs` and
`lsblk` and a folder in place of `/sys/block`; 15 mutations seen red, 2 of them only after the test was made real
(`documentation/audits/build-release-4-2026-11-15/B/redproof-installer-small-disk.txt`). **Not run on a machine.**
## felhom-host-install.sh v1.37.0 (2026-11-15) — a new box trusts Proxmox by a copy of its own root CA (R-1380, D80) — TAGGED `installer-v1.37.0` at `6174944f` and published on the operator's yes (2026-11-15), after one fresh install with this file (`documentation/tests/golden-0.353.0-2026-11-15/fresh-install/`)
- `SCRIPT_VERSION` 1.36.1 → 1.37.0 (2026-11-15), so the file a fresh install proves is the file the tag will name.
+82 -3
View File
@@ -80,6 +80,10 @@
#
# Required:
# --customer-id ID Customer (must already exist in the hub)
# --accept-small-disk OPERATOR ONLY. An appliance install stops when the system disk (the disk
# that holds the `pve` volume group) is below 200 GB, or when its size cannot
# be read. This flag goes on, prints the cost and records small_disk in the
# install state. A byo host is only warned and needs no flag (D83).
# --mode appliance|byo Install profile (REQUIRED for install/--resume — no default):
# appliance a Felhom-owned/managed box. Full Day-0 incl. the
# break-glass root@pam credential (step 4b).
@@ -194,7 +198,7 @@
set -euo pipefail
SCRIPT_VERSION="1.37.0" # the SINGLE version source (F-1): -h and the run banners follow it.
SCRIPT_VERSION="1.38.0" # the SINGLE version source (F-1): -h and the run banners follow it.
# The hub used to carry a copy for its Setup tab; R-94 DELETED it
# (2026-08-02) because the hub cannot know which version a box runs —
# the Setup command fetches this script at run time. scripts/
@@ -280,6 +284,7 @@ PRESERVE_FROM=""
PRESERVE_STATE_FROM="" # dir holding a prior local-api.{crt,key} + local-tokens.log to carry over (keeps the pin stable across a reinstall)
ALLOW_NEW_LEAF=false # opt-in to intentionally regenerate the agent leaf on a populated host (else the guard refuses)
FORCE=false
ACCEPT_SMALL_DISK=false # --accept-small-disk (D83, `16` §14.5): the operator's named way past the 200 GB rule
FORCE_GITEA_GOLDEN=false
SKIP_PROVISION=false
DRY_RUN=false
@@ -370,6 +375,11 @@ AGENT_CONFIG="" # resolved in preflight
# old name called it a hard floor while the check only warned. No measured floor exists. Pinned by
# scripts/test_hostinstall.py (test_lvm_minimum_is_named_as_what_it_does).
RECOMMENDED_MIN_LVM_GIB=120
# D83 (operator, 2026-11-15; felhom.eu `09` §3 decision 308; `16-storage-physical-identity.md` §14.5): the smallest
# system disk is 200 GB — 200 × 10^9 bytes, so a disk sold as "200 GB" (200,049,647,616 bytes) and a virtual disk
# made as "200G" (200 GiB) both pass, and a 128 GB or 180 GB disk does not.
SYSTEM_DISK_MIN_BYTES=200000000000
SYS_BLOCK_DIR="${SYS_BLOCK_DIR:-/sys/block}" # where the kernel says a disk's size (a test points it elsewhere)
# Runtime carriers (never logged)
PASSPHRASE=""
@@ -1760,6 +1770,7 @@ while [[ $# -gt 0 ]]; do
--preserve-state-from) PRESERVE_STATE_FROM="$2"; shift 2 ;;
--allow-new-leaf) ALLOW_NEW_LEAF=true; shift ;;
--force) FORCE=true; shift ;;
--accept-small-disk) ACCEPT_SMALL_DISK=true; shift ;;
--force-gitea-golden) FORCE_GITEA_GOLDEN=true; shift ;;
--skip-provision) SKIP_PROVISION=true; shift ;;
--uninstall) UNINSTALL=true; shift ;;
@@ -2143,6 +2154,9 @@ step_preflight() {
command -v curl >/dev/null || die "curl not found"
command -v python3>/dev/null || die "python3 not found"
# D83: the system disk's size, before anything is changed (a refused machine is exactly as it was).
check_system_disk
local pvever; pvever=$(pveversion | head -1)
# GL-2 PVE-major gate: byo installs are validated on PVE 9.x ONLY — on a host we don't own, an
# unvalidated major is a refusal, not a warning. Appliance keeps the historical warn-only.
@@ -2394,6 +2408,8 @@ step_preflight() {
if ! $PREFLIGHT_ONLY; then
_state_put customer_id "$CUSTOMER_ID"
_state_put mode "$MODE"
_state_put small_disk "${SMALL_DISK:-false}"
_state_put system_disk_bytes "${SYSTEM_DISK_BYTES:-unknown}"
_state_mark preflight
fi
log_success "pre-flight passed"
@@ -2571,10 +2587,13 @@ step_enroll() {
log_dry "curl -fsS -X POST $HUB_URL/api/v1/host-enroll -H 'X-Retrieval-Password: <pass>' -d '{\"customer_id\":\"$CUSTOMER_ID\"}'"
HOST_ID="<dry-run-host-id>"; HOST_API_KEY="<dry-run-key>"; _state_mark enroll; return 0
fi
local resp code body
local resp code body small_json=""
# D83: an install that went on with --accept-small-disk says so to the hub (on a resume the flag is read from
# the state record the preflight wrote). An older hub ignores the field.
if [[ "${SMALL_DISK:-$(_state_get small_disk || true)}" == "true" ]]; then small_json=',"small_disk":true'; fi
resp=$(curl -sS -w $'\n%{http_code}' -X POST "$HUB_URL/api/v1/host-enroll" \
-H "X-Retrieval-Password: $PASSPHRASE" -H 'Content-Type: application/json' \
-d "{\"customer_id\":\"$CUSTOMER_ID\"}")
-d "{\"customer_id\":\"$CUSTOMER_ID\"${small_json}}")
code=$(tail -n1 <<<"$resp"); body=$(sed '$d' <<<"$resp")
case "$code" in
201) log_success " host MINTED (first enroll)" ;;
@@ -2591,6 +2610,66 @@ step_enroll() {
_state_mark enroll
}
# system_disk_bytes — print "<disk> <bytes>" for the ONE whole disk that holds the `pve` volume group, or print
# nothing when that cannot be read (no `pve` group, two physical volumes, a RAID or another layer under it, no size).
# READS ONLY: pvs, lsblk and one file under /sys/block. The size is the kernel's count of 512-byte sectors.
system_disk_bytes() {
local pvs_out n pv pk kind sectors
pvs_out=$(pvs --noheadings -o pv_name -S vg_name=pve 2>/dev/null | awk 'NF {print $1}' || true)
n=$(awk 'NF' <<<"$pvs_out" | wc -l)
[[ "$n" -eq 1 ]] || return 0
pv="$pvs_out"
pk=$(lsblk -dno PKNAME "$pv" 2>/dev/null | awk 'NF {print $1; exit}' || true)
[[ -n "$pk" ]] || return 0
kind=$(lsblk -dno TYPE "/dev/$pk" 2>/dev/null | awk 'NF {print $1; exit}' || true)
[[ "$kind" == "disk" ]] || return 0
sectors=$(cat "$SYS_BLOCK_DIR/$pk/size" 2>/dev/null || true)
[[ "$sectors" =~ ^[0-9]+$ && "$sectors" -gt 0 ]] || return 0
echo "$pk $((sectors * 512))"
}
# check_system_disk — D83: runs in the preflight, BEFORE anything is changed. Sets SMALL_DISK (true|false) and
# SYSTEM_DISK_BYTES (a number, or "unknown") for the state record that step_preflight writes after its checks.
# appliance, below 200 GB → stop (exit 1), nothing changed; --accept-small-disk goes on and prints the cost
# appliance, size cannot be read → stop and name the flag; with the flag: go on, recorded as small
# byo (the owner's own Proxmox) → a warning only, never a stop
# no --mode (--preflight-only) → a warning only (the mode-specific rule needs the mode)
check_system_disk() {
local got disk bytes gb
SMALL_DISK=false; SYSTEM_DISK_BYTES="unknown"
got=$(system_disk_bytes)
if [[ -z "$got" ]]; then
if [[ "$MODE" != "appliance" ]]; then
log_warn " could not read the system disk's size (no single disk under the 'pve' volume group). Felhom needs a system disk of 200 GB."
return 0
fi
if $ACCEPT_SMALL_DISK; then
SMALL_DISK=true
log_warn " --accept-small-disk: the system disk's size cannot be read; the install goes on. Recorded as small_disk."
return 0
fi
die "Cannot read the system disk's size (no single disk under the 'pve' volume group). Felhom needs a system disk of 200 GB. Nothing was changed. An operator can go on with --accept-small-disk."
fi
disk=${got%% *}; bytes=${got##* }
SYSTEM_DISK_BYTES="$bytes"
gb=$(( bytes / 1000000000 ))
if [[ "$bytes" -ge "$SYSTEM_DISK_MIN_BYTES" ]]; then
log_info " system disk: /dev/$disk, ${gb} GB (the minimum is 200 GB)"
return 0
fi
if [[ "$MODE" != "appliance" ]]; then
log_warn " this machine's system disk (/dev/$disk) is ${gb} GB. Felhom needs 200 GB: with less, the local copies of the box can stop when the disk fills. The install goes on (this host is yours)."
return 0
fi
if $ACCEPT_SMALL_DISK; then
SMALL_DISK=true
log_warn " --accept-small-disk: this machine's system disk (/dev/$disk) is ${gb} GB, below the 200 GB that Felhom needs."
log_warn " The cost: the guest gets less space than a household is promised, and the box's local copies can stop when the disk fills. Recorded as small_disk."
return 0
fi
die "This machine's system disk is ${gb} GB. Felhom needs 200 GB. Nothing was changed. (An operator can install a small test box with --accept-small-disk.)"
}
#-------------------------------------------------------------------------------
# STEP 5 — agent install: fetch+verify the binary, ensure the service user, sudoers, unit
#-------------------------------------------------------------------------------
+173
View File
@@ -851,6 +851,179 @@ def test_pve_trust_is_wired_into_the_agent_config():
assert '%s = "%s"' % (name, path) in wrapper and path in func("resolve_pve_trust"), "the installer and the agent's root step disagree on %s" % name
# ── D83 (R-1370, `16` §14.5): the system disk below 200 GB ───────────────────────────────────────
# The disk is the one under the `pve` volume group; its size is the kernel's sector count. The stubs
# stand for pvs and lsblk, and SYS_BLOCK_DIR for /sys/block — no real disk is read.
GB200_LABEL = 200049647616 # a disk sold as "200 GB"
GIB200 = 200 * 1024 ** 3 # a virtual disk made as "200G"
def _disk_sandbox(disks, pvs_lines=("/dev/sda3",), parent="sda", kind="disk"):
"""disks: {name: bytes}. pvs prints pvs_lines; lsblk says the PV's parent and the parent's type."""
sb = Sandbox()
for name, size in disks.items():
os.makedirs(sb.path("sys", name))
with open(sb.path("sys", name, "size"), "w") as f:
f.write("%d\n" % (size // 512))
sb.stub("pvs", "\n".join('echo " %s"' % l for l in pvs_lines) if pvs_lines else "exit 0")
sb.stub("lsblk", 'case "$*" in *PKNAME*) echo "%s";; *TYPE*) echo "%s";; esac' % (parent, kind))
return sb
def _min_bytes_line():
"""The installer's OWN minimum, read from the script — a test that sets the number itself cannot see it change."""
m = re.search(r"^SYSTEM_DISK_MIN_BYTES=\d+$", SRC, re.M)
assert m, "SYSTEM_DISK_MIN_BYTES not found in the installer"
return m.group(0)
def _disk_run(sb, mode, accept=False):
return sb.run("set -euo pipefail\n" + one_liners() + func("system_disk_bytes") + func("check_system_disk") +
_min_bytes_line() + '; SYS_BLOCK_DIR="$SB/sys"\n'
'MODE="%s"; ACCEPT_SMALL_DISK=%s\ncheck_system_disk\n'
'echo "WENT-ON small=$SMALL_DISK bytes=$SYSTEM_DISK_BYTES"\n' % (mode, "true" if accept else "false"))
def test_small_disk_appliance_is_refused_before_anything_changes():
sb = _disk_sandbox({"sda": 128 * 10 ** 9})
try:
rc, out = _disk_run(sb, "appliance")
assert rc == 1 and "WENT-ON" not in out, "a 128 GB appliance install went on: rc=%s %s" % (rc, out)
assert "This machine's system disk is 128 GB. Felhom needs 200 GB." in out and "Nothing was changed" in out, out
assert "--accept-small-disk" in out, "the refusal does not name the flag: %s" % out
# the check only READS: pvs and lsblk, nothing else was called
called = {l.split()[0] for l in sb.logged().splitlines() if l.strip()}
assert called == {"pvs", "lsblk"}, "the disk check ran more than its two reads: %s" % sorted(called)
finally:
sb.close()
def test_small_disk_the_line_is_200_times_ten_to_the_nine_bytes():
for size, passes in ((GB200_LABEL, True), (200 * 10 ** 9, True), (GIB200, True),
(200 * 10 ** 9 - 512, False), (180 * 10 ** 9, False)):
sb = _disk_sandbox({"sda": size})
try:
rc, out = _disk_run(sb, "appliance")
assert (rc == 0 and "WENT-ON small=false bytes=%d" % size in out) == passes, \
"%d bytes: passes=%s wanted %s: %s" % (size, rc == 0, passes, out)
finally:
sb.close()
def test_small_disk_flag_goes_on_prints_the_cost_and_marks_it():
sb = _disk_sandbox({"sda": 128 * 10 ** 9})
try:
rc, out = _disk_run(sb, "appliance", accept=True)
assert rc == 0 and "WENT-ON small=true bytes=128000000000" in out, out
assert "128 GB" in out and "The cost:" in out and "local copies can stop" in out, "the cost is not printed: %s" % out
finally:
sb.close()
# the flag on a disk that is large enough marks nothing
sb = _disk_sandbox({"sda": GB200_LABEL})
try:
rc, out = _disk_run(sb, "appliance", accept=True)
assert rc == 0 and "WENT-ON small=false" in out, out
finally:
sb.close()
def test_small_disk_byo_host_is_warned_never_refused():
sb = _disk_sandbox({"sda": 128 * 10 ** 9})
try:
rc, out = _disk_run(sb, "byo")
assert rc == 0 and "WENT-ON small=false" in out, "a byo host was stopped: %s" % out
assert "[WARN]" in out and "128 GB" in out and "200 GB" in out, out
finally:
sb.close()
# no --mode (the mode-agnostic --preflight-only): a warning too
sb = _disk_sandbox({"sda": 128 * 10 ** 9})
try:
rc, out = _disk_run(sb, "")
assert rc == 0 and "[WARN]" in out, out
finally:
sb.close()
def test_small_disk_size_that_cannot_be_read_refuses_and_names_the_flag():
cases = {
"no pve volume group": dict(disks={"sda": GB200_LABEL}, pvs_lines=()),
"two physical volumes": dict(disks={"sda": GB200_LABEL, "sdb": GB200_LABEL}, pvs_lines=("/dev/sda3", "/dev/sdb1")),
"a RAID under the group": dict(disks={"md0": GB200_LABEL}, parent="md0", kind="raid1"),
"no parent disk": dict(disks={"sda": GB200_LABEL}, parent=""),
"no size file": dict(disks={"sdb": GB200_LABEL}),
}
for name, kw in cases.items():
sb = _disk_sandbox(**kw)
try:
rc, out = _disk_run(sb, "appliance")
assert rc == 1 and "WENT-ON" not in out, "%s: the install went on: %s" % (name, out)
assert "Cannot read the system disk's size" in out and "--accept-small-disk" in out and "Nothing was changed" in out, "%s: %s" % (name, out)
assert "[ERROR] Cannot read" in out and "system disk is" not in out, "%s: the refusal is not the 'cannot read' one: %s" % (name, out)
rc, out = _disk_run(sb, "appliance", accept=True)
assert rc == 0 and "WENT-ON small=true bytes=unknown" in out, "%s with the flag: %s" % (name, out)
rc, out = _disk_run(sb, "byo")
assert rc == 0 and "[WARN]" in out, "%s on a byo host: %s" % (name, out)
finally:
sb.close()
def test_small_disk_a_large_second_disk_does_not_help():
# the rule reads the SYSTEM disk (the one under `pve`), not the largest disk in the machine
sb = _disk_sandbox({"sda": 128 * 10 ** 9, "sdb": 2000 * 10 ** 9})
try:
rc, out = _disk_run(sb, "appliance")
assert rc == 1 and "128 GB" in out, out
finally:
sb.close()
# and the other way round: a small second disk does not refuse a large system disk
sb = _disk_sandbox({"sda": 512 * 10 ** 9, "sdb": 16 * 10 ** 9})
try:
rc, out = _disk_run(sb, "appliance")
assert rc == 0 and "WENT-ON small=false" in out, out
finally:
sb.close()
def test_small_disk_check_is_wired_first_in_the_preflight_and_recorded():
body = func("step_preflight")
at = body.find("\n check_system_disk\n")
assert at > 0, "step_preflight no longer calls check_system_disk"
for later in ("pveversion | head", "_state_put", "_state_mark", "pvesh get", "systemctl cat", "apt-get", "_byo_disclosure_ack", "mkdir", "curl -"):
first = body.find(later)
assert first == -1 or at < first, "check_system_disk runs AFTER %r — a refused machine may already be changed" % later
assert '_state_put small_disk "${SMALL_DISK:-false}"' in body and '_state_put system_disk_bytes' in body, \
"the preflight does not record small_disk in the install state"
# the flag reaches the variable, and the help names it
assert re.search(r"--accept-small-disk\)\s+ACCEPT_SMALL_DISK=true; shift ;;", SRC), "the flag is not parsed"
assert "# --accept-small-disk" in SRC, "the help does not name the flag"
# the existing pool warning stays as the second check
assert "RECOMMENDED_MIN_LVM_GIB" in body
def _enroll_run(small_state, small_var):
sb = Sandbox()
sb.stub("curl", 'printf \'{"host_id":"h1","api_key":"k1"}\\n201\'')
os.makedirs(sb.path("state"))
with open(sb.path("state", "state.json"), "w") as f:
json.dump({"completed": [], "small_disk": small_state}, f)
rc, out = sb.run("set -euo pipefail\n" + prelude() + func("_state_mark") + func("_state_get") + func("step_enroll") +
'die_live_box() { exit 9; }\nPREFLIGHT_ONLY=false\nSTATE_DIR="$SB/state"; STATE_FILE="$SB/state/state.json"\n'
'HUB_URL=http://hub.invalid; PASSPHRASE=p; CUSTOMER_ID=c1\n%sstep_enroll\n' % small_var)
logged = sb.logged()
sb.close()
return rc, out, logged
def test_small_disk_is_told_to_the_hub_at_the_enrolment():
rc, out, logged = _enroll_run("true", "") # a resume: the flag comes from the state record
assert rc == 0, out
assert '{"customer_id":"c1","small_disk":true}' in logged, "the enrolment does not tell the hub: %s" % logged
rc, out, logged = _enroll_run("false", "SMALL_DISK=true\n") # this run's own check wins
assert rc == 0 and '"small_disk":true' in logged, logged
rc, out, logged = _enroll_run("false", "") # the control: an ordinary box says nothing
assert rc == 0 and '{"customer_id":"c1"}' in logged and "small_disk" not in logged, logged
def main():
tests = [(n, f) for n, f in sorted(globals().items()) if n.startswith("test_") and callable(f)]
fails = 0