Skip to content

feat(proxmox): v1 VM delete + task-status endpoints with protected-VMID guard#93

Merged
pparage merged 2 commits into
feature/gamenet-authoring-v1from
feature/proxmox-action-tracking
Jun 9, 2026
Merged

feat(proxmox): v1 VM delete + task-status endpoints with protected-VMID guard#93
pparage merged 2 commits into
feature/gamenet-authoring-v1from
feature/proxmox-action-tracking

Conversation

@pparage

@pparage pparage commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds DELETE /v1/proxmox/hosts/{host_id}/vms/{vmid} — destroys the guest on Proxmox (purge=1 + destroy-unreferenced-disks=1 when purge), with the protected-VMID guard enforced unconditionally on the delete path (VMID 100/101 + canonical ranges + per-host overrides can never be destroyed). Running guest → 409; auth/unreachable/other → existing error envelope.
  • Adds GET /v1/proxmox/hosts/{host_id}/tasks/{upid:path}/status — polls a launched action's UPID to real completion. UPID declared as {upid:path} (colons preserved) and percent-encoded (quote(..., safe='')) for the outbound Proxmox call. New TaskStatus schema; unexpected status values coerced defensively so they can't escape the error envelope as a 500.
  • Refactors the inline VMID guard into a shared _assert_vmid_safe(row, vmid, action) — behavior preserved for vm_status_action (still gated by _DESTRUCTIVE_ACTIONS), called unconditionally by vm_delete.
  • Hardens running-guest detection (matches qemu/LXC phrasings + explicit Proxmox 409).
  • Fixes a latent NameError: Any on the retired v0 delete path (app/routes/vms.py).

These endpoints back the deployer-ui "Proxmox Action Tracking" feature (confirmed delete/lifecycle tracked to task completion via UPID polling).

Test Plan

  • pytest — 391 passed
  • test_vm_delete_happy_path (purge params), test_vm_delete_refuses_protected_vmid (VMID 100 → 409, no DELETE reaches Proxmox), test_vm_delete_running_guest_conflict, test_vm_delete_running_guest_qemu_process_phrasing
  • test_task_status_stopped_ok (percent-encoded UPID in outbound URL), test_task_status_stopped_error, test_task_status_unexpected_status_coerced_to_stopped
  • Existing test_vm_action_guards_protected_vmids_on_destructive still passes (guard refactor behavior-preserving)

@pparage pparage merged commit a649aff into feature/gamenet-authoring-v1 Jun 9, 2026
1 check passed
@pparage pparage deleted the feature/proxmox-action-tracking branch June 11, 2026 12:43
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