Skip to content

Ask when the preselected storage cannot hold the content - #51

Merged
MickLesk merged 1 commit into
mainfrom
fix/storage-preselect-invalid
Sep 21, 2026
Merged

MickLesk merged 1 commit into
mainfrom
fix/storage-preselect-invalid

Conversation

@MickLesk

@MickLesk MickLesk commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

✍️ Description

i had issues after rebuild my hdd / ssd storages on my node2 (replaced and ordered).
the default.vars naming a storage that no longer takes vztmpl hangs the run.

🚀  Creating a InvoiceShelf LXC using the above default settings
  ✔️  Storage space validated
  💡   Preselected storage 'local' does not support content 'vztmpl' (or not found)
^C

Nothing is drawn and nothing exits. The cause:

while true; do
  if [[ -z "${var_template_storage:-}" ]]; then
    if select_storage template; then ...; break; fi
  fi
done

var_template_storage is non-empty exactly when default.vars supplied it, which is the only way to reach this branch — so the body never runs, select_storage is never called, and there is no break. It spins until Ctrl+C. The container branch has no loop, but it silently keeps the unusable value and fails later.

🔗 Related Issue

None filed — reported directly with the transcript above.

✅ Prerequisites (X in brackets)

  • Self-review completed
  • Tested thoroughly – see below
  • No security risks
  • API.txt regenerated – _storage_preselect_recover is internal; no loader snapshot changes

🧪 Testing

_storage_preselect_recover and _write_storage_to_vars extracted from the files, select_storage and whiptail stubbed, against a synthetic default.vars:

# Check Result
1 invalid preselect → asks, yes → key rewritten, no duplicate, other keys untouched PASS
2 user declines → file untouched PASS
3 no default.vars in play → selects, writes nothing, rc 0 PASS
4 nothing selectable → rc 1, caller exits instead of looping PASS
5 chosen storage equals the stale one → no prompt, no write PASS
6 key absent from the file → nothing added PASS
7 the replaced loop, bounded to 3s → still spinning, never asks PASS

Not run on a Proxmox host. bash -n passes on both files.

🛠️ Type of Change (X in brackets)

  • 🐞 Bug fix

A storage named in default.vars that no longer takes vztmpl left the run
here:

  while true; do
    if [[ -z "${var_template_storage:-}" ]]; then
      if select_storage template; then ...; break; fi
    fi
  done

The variable is set precisely when default.vars supplied it, so the body
never ran, nothing was asked and nothing broke out. The container branch
had no loop but silently kept the unusable value instead.

Both now go through _storage_preselect_recover: it asks, and when the
stale name came from default.vars it offers to correct the file so the
next run does not stop at the same place. Declining leaves the file
alone; cancelling the dialog exits with the storage code instead of
spinning.

Fixes the hang reported on InvoiceShelf with var_template_storage=local.
@github-actions

Copy link
Copy Markdown
Contributor

Try this branch

The engine and the scripts resolve independently, so a production script can
be run against the engine from this PR by setting one variable:

COMMUNITY_SCRIPTS_CORE_URL=https://raw.githubusercontent.com/community-scripts/core/fix/storage-preselect-invalid \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/ct/debian.sh)"

Swap ct/debian.sh for whatever exercises the change.

This PR touches pve/, so it needs a Proxmox VE host.

Run a script from a fork as well
curl -fsSL https://raw.githubusercontent.com/community-scripts/core/fix/storage-preselect-invalid/tools/run.sh |
  bash -s -- https://raw.githubusercontent.com/YOU/ProxmoxVED/your-branch ct/debian.sh \
             https://raw.githubusercontent.com/community-scripts/core/fix/storage-preselect-invalid

Note that run.sh is reached through a pipe, so the script it starts inherits
an exhausted stdin. Whiptail is fine — it opens /dev/tty — but a plain read
would see EOF. The single-variable form above does not have that problem.

Useful flags while testing

dev_mode=net logs every engine fetch with status and duration, which is the
quickest way to confirm the branch is really being used. dev_mode=keep stops a
failed build from deleting the container along with the evidence.

@MickLesk

Copy link
Copy Markdown
Member Author
image image image

@MickLesk
MickLesk merged commit 7ff170d into main Sep 21, 2026
4 checks passed
@github-actions
github-actions Bot deleted the fix/storage-preselect-invalid branch September 21, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant