Proxmox: stop early when the node's cluster has no quorum

Without quorum /etc/pve is read-only, so pct create and pvesm set fail with
cfs lock errors. lxc mode now checks pvecm status first and explains the
fixes (pvecm expected 1 for now, or separating the node from the cluster).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 18:44:41 -08:00
parent 310f78c7df
commit a96ae4e825
4 changed files with 40 additions and 0 deletions

View file

@ -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. - **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. - **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. - **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 #### Removing a Docker install from a Proxmox node

View file

@ -179,6 +179,7 @@ lxc_install() {
local tag="netmon-$ROLE" ctname script ip k port=${!PORT_KEY} 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 if [ "$ROLE" = hub ]; then ctname=netmon-hub; else ctname="netmon-probe-$(hostname -s | tr -c 'a-zA-Z0-9-\n' '-')"; fi
step "proxmox container" step "proxmox container"
check_quorum
CTID=$(find_ct "$tag") CTID=$(find_ct "$tag")
if [ -n "$CTID" ]; then log "reusing container $CTID (tagged $tag)"; else create_ct "$ctname" "$tag"; fi 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" pct status "$CTID" | grep -q running || pct start "$CTID"
@ -210,6 +211,17 @@ lxc_install() {
echo " uninstall: pct stop $CTID && pct destroy $CTID" 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. # The container this installer made before, found by its tag.
find_ct() { find_ct() {
local id local id

View file

@ -174,6 +174,7 @@ lxc_install() {
local tag="netmon-$ROLE" ctname script ip k port=${!PORT_KEY} 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 if [ "$ROLE" = hub ]; then ctname=netmon-hub; else ctname="netmon-probe-$(hostname -s | tr -c 'a-zA-Z0-9-\n' '-')"; fi
step "proxmox container" step "proxmox container"
check_quorum
CTID=$(find_ct "$tag") CTID=$(find_ct "$tag")
if [ -n "$CTID" ]; then log "reusing container $CTID (tagged $tag)"; else create_ct "$ctname" "$tag"; fi 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" pct status "$CTID" | grep -q running || pct start "$CTID"
@ -205,6 +206,17 @@ lxc_install() {
echo " uninstall: pct stop $CTID && pct destroy $CTID" 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. # The container this installer made before, found by its tag.
find_ct() { find_ct() {
local id local id

View file

@ -124,3 +124,18 @@ export -f pct pvesh pveam pvesm id
assert r.returncode != 0 assert r.returncode != 0
assert "gmktec-nvme" in r.stderr and "disabled" in r.stderr and "LXC_STORAGE" in r.stderr 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 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