[Bug] sanitize_boot_order never finds a boot order, so it never removes a stale device
Describe the bug
sanitize_boot_order (pegaprox/core/manager.py) is meant to drop from the boot order the devices a VM no longer has (the "invalid bootorder: device does not exist" case, NS Feb 2026). It always answers "No boot order to sanitize", whatever the VM holds.
It reads the boot line and looks the devices up in the dict get_vm_config returns:
config = config_result.get('config', {})
boot_val = config.get('boot', '')
...
if dev in config or (dev == 'net0' and vm_type == 'qemu'):
get_vm_config returns the parsed config (_parse_vm_config), with the Proxmox keys under raw:
parsed = self._parse_vm_config(config, vm_type)
parsed['raw'] = config
The parsed dict has no top-level boot, and no scsi0, ide2 or net0 key. So boot_val is empty and the function returns before it compares anything.
Two callers:
delete_vmcalls it before every delete, "to prevent storage volume does not exist errors". That step does nothing today.POST /api/clusters/<id>/vms/<node>/<type>/<vmid>/sanitize-boot-order. I found no caller for it inweb/src.
Steps to Reproduce
- Take a VM whose config has
boot: order=scsi0;ide2;net0and noide2anymore. POST /api/clusters/<id>/vms/<node>/qemu/<vmid>/sanitize-boot-order- The answer is
{"success": true, "message": "No boot order to sanitize", "changed": false}and nothing is sent to Proxmox.
With a stand-in for the Proxmox answers, on Testing 99df4577:
E AssertionError: {'success': True, 'message': 'No boot order to sanitize', 'changed': False}
Expected behavior
The boot order is rewritten without ide2, as the docstring says.
Reading both from raw is a two-line change. I have it on a branch with tests (raw = config.get('raw', config)). I did not open a PR, because turning the function on changes more than the function. These are your calls:
delete_vmwould start sending aPUT .../configbefore deleting any VM with a stale boot order. It is wrapped in atryand the delete goes on if it fails, but it is a write to Proxmox that does not happen today.- When no device in the order exists anymore, the function writes
order=net0for a QEMU VM. It countsnet0as valid, even on a VM without a NIC. Proxmox may refuse that. On the route, an answer that is a 200 today could become an error. - If the route has no caller, it may be simpler to remove it than to fix it.
Tell me which way you want it and I will send the PR that way, or leave it to you.
Environment
- PegaProx Version: Testing at 99df4577
- Installation Method: Manual (git clone), tests run in a python:3.12 container
- OS: not involved
- Browser: not involved
- Behind Reverse Proxy? not involved
- UI? not involved
Logs
E AssertionError: {'success': True, 'message': 'No boot order to sanitize', 'changed': False}
E assert (True is True and False is True)
Screenshots
None.
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
- [x] I've put enough in here that someone can start on it without asking me three questions first
- [x] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄
Confirmed, thanks. get_vm_config puts the boot line under options and the Proxmox keys under raw, so sanitize_boot_order reads an empty boot value and returns before it compares anything. Noted as a bug, the fix is in the works.
Marcus
This one is in 1.5.0 now, the boot order cleanup finds the stale device again. Thanks for the clear write-up, closing.