Proxmox: explain why no container storage qualifies; pick storage before the template
On a cluster node whose container storages are all disabled for that node, the installer said only "no active storage". It now lists the storages that allow containers with their status on this node, explains "disabled", and gives the two fixes. Storage is checked before any template download, so a failed run leaves nothing behind. Also drops --enabled from the pvesm query so disabled storages show in that listing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1dad1ad85d
commit
fbe1a1be43
3 changed files with 65 additions and 18 deletions
33
install.sh
33
install.sh
|
|
@ -214,7 +214,8 @@ find_ct() {
|
|||
}
|
||||
|
||||
create_ct() {
|
||||
local ctname=$1 tag=$2 tstore=${LXC_TEMPLATE_STORAGE:-local} storage=${LXC_STORAGE:-} tmpl name
|
||||
local ctname=$1 tag=$2 tstore=${LXC_TEMPLATE_STORAGE:-local} storage tmpl name
|
||||
storage=$(pick_storage)
|
||||
CTID=${LXC_ID:-$(pvesh get /cluster/nextid)}
|
||||
tmpl=$(pveam list "$tstore" 2>/dev/null | awk '{ print $1 }' | grep -E 'vztmpl/debian-1[23]-standard' | sort -V | tail -1 || true)
|
||||
if [ -z "$tmpl" ]; then
|
||||
|
|
@ -225,14 +226,6 @@ create_ct() {
|
|||
pveam download "$tstore" "$name" >/dev/null || die "could not download $name to $tstore (set LXC_TEMPLATE_STORAGE)"
|
||||
tmpl="$tstore:vztmpl/$name"
|
||||
fi
|
||||
if [ -z "$storage" ]; then
|
||||
local avail
|
||||
avail=$(pvesm status --content rootdir --enabled 1 2>/dev/null | awk 'NR > 1 && $3 == "active" { print $1 }')
|
||||
for name in local-lvm local-zfs $avail; do
|
||||
if echo "$avail" | grep -qx "$name"; then storage=$name; break; fi
|
||||
done
|
||||
[ -n "$storage" ] || die "no active storage for containers found; set LXC_STORAGE"
|
||||
fi
|
||||
log "creating container $CTID ($ctname) from $tmpl on $storage, bridge ${LXC_BRIDGE:-vmbr0}"
|
||||
pct create "$CTID" "$tmpl" --hostname "$ctname" --cores "${LXC_CORES:-1}" --memory "${LXC_MEMORY:-512}" --swap 256 \
|
||||
--rootfs "$storage:${LXC_DISK:-4}" \
|
||||
|
|
@ -241,6 +234,28 @@ create_ct() {
|
|||
--description "Network Monitor $ROLE, created by the $NAME installer" >/dev/null || die "pct create failed"
|
||||
}
|
||||
|
||||
# Storage for the container's disk: LXC_STORAGE, else an active storage on this node that
|
||||
# allows containers (content rootdir), preferring local-lvm and local-zfs. In a cluster,
|
||||
# storages assigned to other nodes show as "disabled" here and don't count.
|
||||
pick_storage() {
|
||||
local avail name line
|
||||
if [ -n "${LXC_STORAGE:-}" ]; then echo "$LXC_STORAGE"; return; fi
|
||||
avail=$(pvesm status --content rootdir 2>/dev/null | awk 'NR > 1 && $3 == "active" { print $1 }' || true)
|
||||
for name in local-lvm local-zfs $avail; do
|
||||
if echo "$avail" | grep -qx "$name"; then echo "$name"; return; fi
|
||||
done
|
||||
{
|
||||
printf '\nerror: no storage on this node can hold the container.\n'
|
||||
printf 'Storages that allow containers (content rootdir), and their status on %s:\n' "$(hostname)"
|
||||
pvesm status --content rootdir 2>/dev/null | awk 'NR > 1 { printf " %-20s %s\n", $1, $3 }'
|
||||
printf '"disabled" means not enabled for this node (Datacenter > Storage > Enable / Nodes).\n'
|
||||
printf 'Fix one of them, or let the local directory storage hold containers:\n'
|
||||
printf ' pvesm set local --content %s,rootdir\n' "$(awk '/^dir: local$/ { f = 1; next } f && /^[a-z]+:/ { f = 0 } f && $1 == "content" { print $2 }' /etc/pve/storage.cfg 2>/dev/null || echo 'backup,iso,vztmpl')"
|
||||
printf 'then run the installer again with LXC_STORAGE=<name> before bash.\n'
|
||||
} >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
wait_ct_network() {
|
||||
log "waiting for container $CTID to get network"
|
||||
local i=0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue