Handle Proxmox guests missing for an already-VMID'd device; toast instead of alert()
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
/configendpoint with"Configuration file '...' does not exist"rather than a 404.BuildVMStatenow 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 afterstore.GetProvisionedDeviceconfirms 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.Computeoffers acreate_vmaction under the declared VMID instead of blocking, andapply.Deps.DesiredVMIDis threaded through so it actually lands there. The existingBlockerVMIDMissingOnProxmoxblock 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()onhtmx:responseErrorwith 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 AllowCreateWithDeclaredVMIDproduces acreate_vmaction 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 CreateVMcall when never provisioned
Edited by Aiho Tehisaru