Skip to content

fix(proxmox): auto-select snippets-capable storage for cloud-init#154

Merged
astrojerms merged 1 commit into
mainfrom
fix/snippets-storage-autoselect
Jul 20, 2026
Merged

fix(proxmox): auto-select snippets-capable storage for cloud-init#154
astrojerms merged 1 commit into
mainfrom
fix/snippets-storage-autoselect

Conversation

@astrojerms

Copy link
Copy Markdown
Owner

Auto-select a snippets-capable storage (Bootstrap QGA robustness follow-up)

The cloud-init snippet path — qemu-guest-agent enablement and the E1 packages/runcmd vendor snippet — required the configured/disk storage to hold snippets. On a local-lvm-only node it silently no-op'd, which stalls DHCP-mode IP discovery for ~10 minutes and drops requested node prep. This is the "real fix" the roadmap's [~] QGA item called for.

Change

  • client.PickSnippetsStorage(storages, preferred) — pure, unit-tested: prefer the configured storage when it's snippets-capable, else the node's first snippets-capable storage (sorted for determinism), else ok=false.
  • The handler resolves the storage via ListNodeStorages before uploading, so an LVM-default node still lands its snippet on e.g. local.
  • Fail-fast: when a VM explicitly requested packages/runcmd and the node has no snippets-capable storage, create returns an actionable error instead of producing a silently-broken node (e.g. Longhorn's open-iscsi never installed). The best-effort agent-only case (no packages/runcmd) still degrades gracefully — logged, non-fatal — preserving prior behavior.

Hardens both the bootstrap QGA path and the just-shipped E1 per-VM vendor snippet (they share applyCloudInitVendorSnippet).

Tests

  • PickSnippetsStorage: prefer-configured, fallback-when-preferred-incapable, fallback-when-no-preferred, none-capable.
  • Handler: auto-select (LVM default → snippet uploaded to local, cicustom=vendor=local:…) and fail-fast (no snippets storage + packages → error). Existing E1 handler test updated to serve /storage.

Local CI: build, go test ./... (+-race on proxmox), gofmt, vet, staticcheck, golangci-lint (0 issues), modernize — root and the proxmox plugin module — all green.

The cloud-init snippet path (qemu-guest-agent enablement + E1
packages/runcmd) required the configured/disk storage to hold snippets;
on a local-lvm-only node it silently no-op'd, which stalls DHCP-mode IP
discovery for ~10 minutes and drops requested node prep.

- client.PickSnippetsStorage (pure, unit-tested): prefer the configured
  storage when it's snippets-capable, else the node's first snippets-capable
  storage (sorted), else ok=false.
- The handler resolves the storage via ListNodeStorages before uploading,
  so an LVM-default node still lands its snippet on e.g. "local".
- Fail-fast: when a VM explicitly requested packages/runcmd and the node has
  no snippets-capable storage, create returns an actionable error instead of
  a silently-broken node. The best-effort agent-only case still degrades
  gracefully (logged, non-fatal), preserving prior behavior.

Hardens both the bootstrap QGA path and the E1 per-VM vendor snippet (they
share applyCloudInitVendorSnippet).

Tests: PickSnippetsStorage (prefer/fallback/none); handler auto-select
(LVM default → snippet on local) and fail-fast (no snippets storage →
error); existing E1 handler test updated to serve /storage.
@astrojerms
astrojerms merged commit d10a971 into main Jul 20, 2026
6 checks passed
@astrojerms
astrojerms deleted the fix/snippets-storage-autoselect branch July 20, 2026 01:26
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