From 41f8e0bad6f4f8c7036ade665d174fa119a11e6a Mon Sep 17 00:00:00 2001 From: GuillaumeV-cemea <101114641+GuillaumeV-cemea@users.noreply.github.com> Date: Sat, 7 Jun 2025 17:21:44 +0200 Subject: [PATCH] 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 --- .../fragments/10176-fix-proxmox_snap_timeout.yml | 3 +++ plugins/modules/proxmox_snap.py | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/10176-fix-proxmox_snap_timeout.yml diff --git a/changelogs/fragments/10176-fix-proxmox_snap_timeout.yml b/changelogs/fragments/10176-fix-proxmox_snap_timeout.yml new file mode 100644 index 0000000000..17460d5d5b --- /dev/null +++ b/changelogs/fragments/10176-fix-proxmox_snap_timeout.yml @@ -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). diff --git a/plugins/modules/proxmox_snap.py b/plugins/modules/proxmox_snap.py index 158efe99ec..9abc5cf1ad 100644 --- a/plugins/modules/proxmox_snap.py +++ b/plugins/modules/proxmox_snap.py @@ -190,7 +190,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible): def start_instance(self, vm, vmid, timeout): taskid = self.vmstatus(vm, vmid).start.post() - while timeout: + while timeout >= 0: if self.api_task_ok(vm['node'], taskid): return True timeout -= 1 @@ -202,7 +202,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible): def shutdown_instance(self, vm, vmid, timeout): taskid = self.vmstatus(vm, vmid).shutdown.post() - while timeout: + while timeout >= 0: if self.api_task_ok(vm['node'], taskid): return True timeout -= 1 @@ -245,7 +245,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible): else: 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): break if timeout == 0: @@ -265,7 +265,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible): return True taskid = self.snapshot(vm, vmid).delete(snapname, force=int(force)) - while timeout: + while timeout >= 0: if self.api_task_ok(vm['node'], taskid): return True if timeout == 0: @@ -281,7 +281,7 @@ class ProxmoxSnapAnsible(ProxmoxAnsible): return True taskid = self.snapshot(vm, vmid)(snapname).post("rollback") - while timeout: + while timeout >= 0: if self.api_task_ok(vm['node'], taskid): return True if timeout == 0: