feature: Add HA job validation for migration jobs

Fixes: #402
This commit is contained in:
Florian Paul Azim Hoberg
2025-12-16 17:19:44 +01:00
committed by gyptazy
parent d546036a9a
commit d7631ef8f5
2 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
added:
- Add HA job validation for migration jobs (@gytazy). [#402]

View File

@@ -226,8 +226,23 @@ class Balancing:
logger.debug("Starting: get_rebalancing_job_status.")
job = proxmox_api.nodes(guest_current_node).tasks(job_id).status().get()
# Fetch actual migration job status if this got spawned by a HA job
if job["type"] == "hamigrate":
logger.debug(f"Balancing: Job ID {job_id} (guest: {guest_name}) is a HA migration job. Fetching underlying migration job...")
time.sleep(1)
vm_id = int(job["id"])
qm_migrate_jobs = proxmox_api.nodes(guest_current_node).tasks.get(typefilter="qmigrate", vmid=vm_id, start=0, source="active", limit=1)
if len(qm_migrate_jobs) > 0:
job = qm_migrate_jobs[0]
job_id = job["upid"]
logger.debug(f'Overwriting job polling for: ID {job_id} (guest: {guest_name}) by {job}')
else:
logger.debug(f"Balancing: Job ID {job_id} (guest: {guest_name}) is a standard migration job. Proceeding with status check.")
# Watch job id until it finalizes
if job["status"] == "running":
# Note: Unsaved jobs are delivered in uppercase from Proxmox API
if job.get("status", "").lower() == "running":
# Do not hammer the API while
# watching the job status
time.sleep(10)