From 9de76693b7229c6e2c3c20de155df64100978338 Mon Sep 17 00:00:00 2001 From: Nijin Ashok Date: Thu, 23 Nov 2017 00:21:20 +0530 Subject: [PATCH] ovirt_vms: Fix issue in stopping stateless VMs (#32955) Because of wrong condition defined, the module will wait indefinitely for snapshots to be removed and will finally timeout after the timeout interval. --- lib/ansible/modules/cloud/ovirt/ovirt_vms.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py index ad1d2a2fd9c..9550601866b 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_vms.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_vms.py @@ -909,18 +909,23 @@ class VmsModule(BaseModule): ] # Stateless snapshot may be already removed: if snap_stateless: + """ + We need to wait for Active snapshot ID, to be removed as it's current + stateless snapshot. Then we need to wait for staless snapshot ID to + be read, for use, because it will become active snapshot. + """ wait( - service=snapshots_service.snapshot_service(snap_stateless[0].id), + service=snapshots_service.snapshot_service(snap_active.id), condition=lambda snap: snap is None, wait=self.param('wait'), timeout=self.param('timeout'), ) - wait( - service=snapshots_service.snapshot_service(snap_active.id), - condition=lambda snap: snap.snapshot_status == otypes.SnapshotStatus.OK, - wait=self.param('wait'), - timeout=self.param('timeout'), - ) + wait( + service=snapshots_service.snapshot_service(snap_stateless[0].id), + condition=lambda snap: snap.snapshot_status == otypes.SnapshotStatus.OK, + wait=self.param('wait'), + timeout=self.param('timeout'), + ) return True def __attach_disks(self, entity):