Skip to content

Handle Proxmox guests missing for an already-VMID'd device; toast instead of alert()

Aiho Tehisaru requested to merge fix/proxmox-guest-not-found-and-toast into trunk

Summary

  • A device whose NetBox VMID field is already set but has no matching Proxmox guest (e.g. an LXC just created in NetBox, before Rax has ever provisioned it) 500s Proxmox's own /config endpoint with "Configuration file '...' does not exist" rather than a 404. BuildVMState now recognizes that specific message (proxmox.ErrGuestNotFound) and resolves it the same as a fresh, never-provisioned device instead of surfacing a raw 502 error page. Any other 500 (or a genuine 404) still surfaces as an error exactly as before — only that one message is read as "no such guest".
  • Rax will now actually create the VM/LXC under that declared VMID when it's safe to: diff.Options.AllowCreateWithDeclaredVMID (default false everywhere else) is set by the web layer only after store.GetProvisionedDevice confirms Rax has never itself seen a live guest for this device — i.e. DCOps pre-assigned the VMID while creating a genuinely new NetBox device, not an existing VM that got deleted out from under it. When set, diff.Compute offers a create_vm action under the declared VMID instead of blocking, and apply.Deps.DesiredVMID is threaded through so it actually lands there. The existing BlockerVMIDMissingOnProxmox block still fires exactly as before for a device Rax's own store remembers provisioning — that's genuine drift, still requires operator reconciliation.
  • Replaced the blocking alert() on htmx:responseError with a dismissible toast, so one Proxmox/NetBox error doesn't stall the whole tab.

Test plan

  • go build, go vet, gofmt -l, go test ./... all green (local go1.26.7)
  • proxmox: guest-not-found 500 resolves without error; an unrelated 500 still errors and does not wrap ErrGuestNotFound; existing 404-stays-an-error test still passes unchanged
  • diff: new test confirms AllowCreateWithDeclaredVMID produces a create_vm action under the declared VMID with no blocker; existing blocked-by-default test unchanged
  • web: new tests cover both branches end-to-end — blocked+no-action when previously provisioned (seeded via store), allowed+action+correct VMID in the actual CreateVM call when never provisioned

🤖 Generated with Claude Code

https://claude.ai/code/session_01U9buZPRQy7YXLodkSPFFik

Edited by Aiho Tehisaru

Merge request reports

Loading