Properly handle proxmox_snap timeout parameter (#10176)

* fix: issue #10175

There is some code to handle timeout, but due to an erroneous while
test, it was never called. Use timeout >= 0 instead of timeout, so the
timeout code can be called, and properly handle timeout.

* add changelog

* Adjust changelog fragment.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
GuillaumeV-cemea 2025-06-07 17:21:44 +02:00 committed by GitHub
parent c9cd54a845
commit 41f8e0bad6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -0,0 +1,3 @@
---
minor_changes:
- proxmox_snap - correctly handle proxmox_snap timeout parameter (https://github.com/ansible-collections/community.proxmox/issues/73, https://github.com/ansible-collections/community.proxmox/issues/95, https://github.com/ansible-collections/community.general/pull/10176).

View file

@ -190,7 +190,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible):
def start_instance(self, vm, vmid, timeout): def start_instance(self, vm, vmid, timeout):
taskid = self.vmstatus(vm, vmid).start.post() taskid = self.vmstatus(vm, vmid).start.post()
while timeout: while timeout >= 0:
if self.api_task_ok(vm['node'], taskid): if self.api_task_ok(vm['node'], taskid):
return True return True
timeout -= 1 timeout -= 1
@ -202,7 +202,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible):
def shutdown_instance(self, vm, vmid, timeout): def shutdown_instance(self, vm, vmid, timeout):
taskid = self.vmstatus(vm, vmid).shutdown.post() taskid = self.vmstatus(vm, vmid).shutdown.post()
while timeout: while timeout >= 0:
if self.api_task_ok(vm['node'], taskid): if self.api_task_ok(vm['node'], taskid):
return True return True
timeout -= 1 timeout -= 1
@ -245,7 +245,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible):
else: else:
taskid = self.snapshot(vm, vmid).post(snapname=snapname, description=description, vmstate=int(vmstate)) taskid = self.snapshot(vm, vmid).post(snapname=snapname, description=description, vmstate=int(vmstate))
while timeout: while timeout >= 0:
if self.api_task_ok(vm['node'], taskid): if self.api_task_ok(vm['node'], taskid):
break break
if timeout == 0: if timeout == 0:
@ -265,7 +265,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible):
return True return True
taskid = self.snapshot(vm, vmid).delete(snapname, force=int(force)) taskid = self.snapshot(vm, vmid).delete(snapname, force=int(force))
while timeout: while timeout >= 0:
if self.api_task_ok(vm['node'], taskid): if self.api_task_ok(vm['node'], taskid):
return True return True
if timeout == 0: if timeout == 0:
@ -281,7 +281,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible):
return True return True
taskid = self.snapshot(vm, vmid)(snapname).post("rollback") taskid = self.snapshot(vm, vmid)(snapname).post("rollback")
while timeout: while timeout >= 0:
if self.api_task_ok(vm['node'], taskid): if self.api_task_ok(vm['node'], taskid):
return True return True
if timeout == 0: if timeout == 0: