fix(create-proxmox-resource): fix VM disk never attaching after import #66

Closed
beatzaplenty wants to merge 1 commits from worktree-warm-discovering-moon into main
Owner

Three bugs combined to leave every VM build with a shell but no boot disk:

  1. The remote build script moved the raw image to /var/lib/vz/import/ before
    qm importdisk could use it. If the mv failed (cross-filesystem copy, sudo
    path, or any other reason) the remote script exited non-zero -- but the
    local script's set -e handling of the SSH heredoc was inconsistent, so
    qm create sometimes ran anyway, leaving a diskless VM shell.

    Fix: skip the mv entirely. The diskoImagesScript writes .raw into
    its CWD (the remote repo dir, $out = $PWD at invocation). Import directly
    from that path; clean it up after a successful import.

  2. The qm importdisk output regex expected "Successfully imported disk as '...'"
    but current Proxmox emits "unusedN: successfully imported disk '...'"
    (lowercase, no "as"). The grep returned no match and exited 1.

  3. The disk_id assignment used $(... | grep ...) without || true inside the
    substitution. With set -euo pipefail, a non-zero grep exit aborts the
    script before the fallback could run -- so the VM was always left with an
    unattached unused0 disk.

    Fix: update the primary regex to match the actual PVE format; add || true
    inside the substitution so set -e never fires on a grep miss; add a qm
    config fallback (scan for unusedN: lines) that works regardless of PVE
    output format changes.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_011uRcikkTp3D5VbXj2DwNpQ

Three bugs combined to leave every VM build with a shell but no boot disk: 1. The remote build script moved the raw image to /var/lib/vz/import/ before qm importdisk could use it. If the mv failed (cross-filesystem copy, sudo path, or any other reason) the remote script exited non-zero -- but the local script's set -e handling of the SSH heredoc was inconsistent, so qm create sometimes ran anyway, leaving a diskless VM shell. Fix: skip the mv entirely. The diskoImagesScript writes <hostname>.raw into its CWD (the remote repo dir, $out = $PWD at invocation). Import directly from that path; clean it up after a successful import. 2. The qm importdisk output regex expected "Successfully imported disk as '...'" but current Proxmox emits "unusedN: successfully imported disk '...'" (lowercase, no "as"). The grep returned no match and exited 1. 3. The disk_id assignment used $(... | grep ...) without || true inside the substitution. With set -euo pipefail, a non-zero grep exit aborts the script before the fallback could run -- so the VM was always left with an unattached unused0 disk. Fix: update the primary regex to match the actual PVE format; add || true inside the substitution so set -e never fires on a grep miss; add a qm config fallback (scan for unusedN: lines) that works regardless of PVE output format changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011uRcikkTp3D5VbXj2DwNpQ
beatzaplenty added 1 commit 2026-07-25 22:22:08 +00:00
fix(create-proxmox-resource): fix VM disk never attaching after import
Check NixOS configurations / eval-hosts (pull_request) Successful in 10m31s
c90f2cffc0
Three bugs combined to leave every VM build with a shell but no boot disk:

1. The remote build script moved the raw image to /var/lib/vz/import/ before
   qm importdisk could use it. If the mv failed (cross-filesystem copy, sudo
   path, or any other reason) the remote script exited non-zero -- but the
   local script's set -e handling of the SSH heredoc was inconsistent, so
   qm create sometimes ran anyway, leaving a diskless VM shell.

   Fix: skip the mv entirely. The diskoImagesScript writes <hostname>.raw into
   its CWD (the remote repo dir, $out = $PWD at invocation). Import directly
   from that path; clean it up after a successful import.

2. The qm importdisk output regex expected "Successfully imported disk as '...'"
   but current Proxmox emits "unusedN: successfully imported disk '...'"
   (lowercase, no "as"). The grep returned no match and exited 1.

3. The disk_id assignment used $(... | grep ...) without || true inside the
   substitution. With set -euo pipefail, a non-zero grep exit aborts the
   script before the fallback could run -- so the VM was always left with an
   unattached unused0 disk.

   Fix: update the primary regex to match the actual PVE format; add || true
   inside the substitution so set -e never fires on a grep miss; add a qm
   config fallback (scan for unusedN: lines) that works regardless of PVE
   output format changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011uRcikkTp3D5VbXj2DwNpQ
beatzaplenty closed this pull request 2026-07-25 22:22:31 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No labels
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: beatzaplenty/nixos#66