Skip to content

Fix ProxmoxMachine deletion to wait for stop/destroy tasks#744

Open
Leonorus wants to merge 3 commits intoionos-cloud:mainfrom
Leonorus:main
Open

Fix ProxmoxMachine deletion to wait for stop/destroy tasks#744
Leonorus wants to merge 3 commits intoionos-cloud:mainfrom
Leonorus:main

Conversation

@Leonorus
Copy link
Copy Markdown

@Leonorus Leonorus commented May 5, 2026

Issue #, if available:
Fixes #742

Description of changes:
- Make ProxmoxMachine deletion task-aware for async Proxmox qmstop and qmdestroy tasks.
- Return and track the qmstop task for running VMs instead of immediately submitting qmdestroy while the VM may still be running.
- Store deletion task UPIDs in status.taskRef and requeue while stop/destroy tasks are still running.
- Keep the finalizer and node location until deletion is confirmed by a successful destroy task and VMID-free check.
- Surface deletion task failures with VirtualMachineProvisioned=False, Reason=DeletionFailed, and the Proxmox task exit status, e.g. qmdestroy: VM 103 is running - destroy failed.
- Preserve safe cleanup paths for already-free VMIDs, missing/expired tasks, and unassigned/reserved VMIDs.
- Add regression coverage for deletion task tracking, failed destroy handling, VMID-free confirmation, transient task lookup failures, and running-VM stop-before-destroy behavior.

Comment thread internal/service/taskservice/task.go Outdated
Comment thread internal/service/taskservice/task.go Outdated
Comment thread internal/service/vmservice/delete.go Outdated
Co-authored-by: Vic Kerr <w@kerr.sh>
@wikkyk
Copy link
Copy Markdown
Collaborator

wikkyk commented May 6, 2026

Don't worry about the test 'failure' - it's only the sonarqube report step that's failing (I'm working on improving the workflow).

@wikkyk
Copy link
Copy Markdown
Collaborator

wikkyk commented May 6, 2026

Thanks. I'll let @65278 do another review because he knows that part of the code better.

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.

v0.8.1: ProxmoxMachine deletion does not track async stop/destroy task failures; stale VM can be re-adopted after VM is running - destroy failed

2 participants