diff --git a/README.md b/README.md index 258c9f6..19c38b2 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Notes: - **What the probe measures:** the container sits on the node's bridge, so its traffic leaves through the node's NIC, and the probe measures that node's link. - **Neighbors:** a probe in a container sees only the devices it has talked to, not everything the node sees. AdGuard is the main source of the client list, so this rarely matters. - **Ping:** inside an unprivileged container, the ping setting is limited to the container's mapped groups (0–65535). The installer handles that. +- **Quorum:** a node in a cluster without quorum can't create containers, because `/etc/pve` is read-only. The installer checks first and stops with an explanation. On a lone node left from a dead cluster, `pvecm expected 1` restores quorum until the next reboot. Separating the node from the cluster fixes it for good, and without quorum guests also won't start at boot. #### Removing a Docker install from a Proxmox node diff --git a/install-probe.sh b/install-probe.sh index e5e26d4..95fad4f 100755 --- a/install-probe.sh +++ b/install-probe.sh @@ -179,6 +179,7 @@ lxc_install() { local tag="netmon-$ROLE" ctname script ip k port=${!PORT_KEY} if [ "$ROLE" = hub ]; then ctname=netmon-hub; else ctname="netmon-probe-$(hostname -s | tr -c 'a-zA-Z0-9-\n' '-')"; fi step "proxmox container" + check_quorum CTID=$(find_ct "$tag") if [ -n "$CTID" ]; then log "reusing container $CTID (tagged $tag)"; else create_ct "$ctname" "$tag"; fi pct status "$CTID" | grep -q running || pct start "$CTID" @@ -210,6 +211,17 @@ lxc_install() { echo " uninstall: pct stop $CTID && pct destroy $CTID" } +# Without quorum /etc/pve is read-only: no container can be created or changed. +# A standalone node (no cluster) has no corosync config, and pvecm status fails: that's fine. +check_quorum() { + if pvecm status 2>/dev/null | grep -Eq '^Quorate:[[:space:]]+No'; then + die "this node is in a cluster without quorum, so /etc/pve is read-only and no container can be created. + If the other cluster nodes are gone: run 'pvecm expected 1' (until the next reboot or corosync restart), + or separate the node from the cluster for good (Proxmox docs: 'Separate a node without reinstalling'). + Without quorum, Proxmox also won't start guests at boot." + fi +} + # The container this installer made before, found by its tag. find_ct() { local id diff --git a/install.sh b/install.sh index 7e32f11..193db8a 100755 --- a/install.sh +++ b/install.sh @@ -174,6 +174,7 @@ lxc_install() { local tag="netmon-$ROLE" ctname script ip k port=${!PORT_KEY} if [ "$ROLE" = hub ]; then ctname=netmon-hub; else ctname="netmon-probe-$(hostname -s | tr -c 'a-zA-Z0-9-\n' '-')"; fi step "proxmox container" + check_quorum CTID=$(find_ct "$tag") if [ -n "$CTID" ]; then log "reusing container $CTID (tagged $tag)"; else create_ct "$ctname" "$tag"; fi pct status "$CTID" | grep -q running || pct start "$CTID" @@ -205,6 +206,17 @@ lxc_install() { echo " uninstall: pct stop $CTID && pct destroy $CTID" } +# Without quorum /etc/pve is read-only: no container can be created or changed. +# A standalone node (no cluster) has no corosync config, and pvecm status fails: that's fine. +check_quorum() { + if pvecm status 2>/dev/null | grep -Eq '^Quorate:[[:space:]]+No'; then + die "this node is in a cluster without quorum, so /etc/pve is read-only and no container can be created. + If the other cluster nodes are gone: run 'pvecm expected 1' (until the next reboot or corosync restart), + or separate the node from the cluster for good (Proxmox docs: 'Separate a node without reinstalling'). + Without quorum, Proxmox also won't start guests at boot." + fi +} + # The container this installer made before, found by its tag. find_ct() { local id diff --git a/tests/test_installers.py b/tests/test_installers.py index c922e20..b73f7ee 100644 --- a/tests/test_installers.py +++ b/tests/test_installers.py @@ -124,3 +124,18 @@ export -f pct pvesh pveam pvesm id assert r.returncode != 0 assert "gmktec-nvme" in r.stderr and "disabled" in r.stderr and "LXC_STORAGE" in r.stderr assert not (tmp_path / "calls").exists() # nothing downloaded before giving up + + +def test_proxmox_without_quorum_stops_early(tmp_path): + stubs = f''' +pct() {{ echo "pct $*" >> {tmp_path}/calls; true; }} +pvecm() {{ printf "Votequorum information\\nExpected votes: 3\\nQuorate: No\\n"; }} +pvesm() {{ echo "pvesm $*" >> {tmp_path}/calls; true; }} +id() {{ if [ "$1" = -u ]; then echo 0; else command id "$@"; fi; }} +export -f pct pvecm pvesm id +''' + (tmp_path / "pve").mkdir() + env = {**os.environ, "NETMON_PVE_DIR": str(tmp_path / "pve"), "INSTALL_DIR": str(tmp_path / "opt")} + r = subprocess.run(["bash", "-c", stubs + "bash install.sh"], cwd=ROOT, capture_output=True, text=True, env=env, timeout=60) + assert r.returncode != 0 and "without quorum" in r.stderr and "pvecm expected 1" in r.stderr + assert not (tmp_path / "calls").exists() # stopped before touching pct or storage