Martin Betak has uploaded a new change for review.

Change subject: migration: Enable cancellation of migrations during retry
......................................................................

migration: Enable cancellation of migrations during retry

Migrated _migrationCancelledEvent to proper threading.Event() and used wait
instead of sleep in the retry loop to enable cancellation of migrations without
any delays if a retry is in effect.

Change-Id: Ic638f67ecf311be0b81d1a7a1afe227e45f816d1
Signed-off-by: Martin Betak <mbe...@redhat.com>
---
M vdsm/virt/migration.py
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/55742/1

diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 6bc8287..e6a5f92 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -119,7 +119,7 @@
         self._progress = 0
         threading.Thread.__init__(self)
         self._preparingMigrationEvt = True
-        self._migrationCanceledEvt = False
+        self._migrationCanceledEvt = threading.Event()
         self._monitorThread = None
         self._destServer = None
         self._completed = False
@@ -333,7 +333,7 @@
             while self._progress < 100:
                 try:
                     with SourceThread._ongoingMigrations:
-                        if self._migrationCanceledEvt:
+                        if self._migrationCanceledEvt.is_set():
                             self._raiseAbortError()
                         self.log.debug("migration semaphore acquired "
                                        "after %d seconds",
@@ -359,7 +359,7 @@
                                                   'migration_retry_timeout')
                     self.log.debug("Migration destination busy. Initiating "
                                    "retry in %d seconds.", retry_timeout)
-                    time.sleep(retry_timeout)
+                    self._migrationCanceledEvt.wait(retry_timeout)
         except MigrationDestinationSetupError as e:
             self._recover(str(e))
             # we know what happened, no need to dump hollow stack trace
@@ -436,7 +436,7 @@
         # we may return migration stop but it will start at libvirt
         # side
         self._preparingMigrationEvt = False
-        if not self._migrationCanceledEvt:
+        if not self._migrationCanceledEvt.is_set():
             # TODO: use libvirt constants when bz#1222795 is fixed
             params = {VIR_MIGRATE_PARAM_URI: str(muri),
                       VIR_MIGRATE_PARAM_BANDWIDTH: self._maxBandwidth}
@@ -489,7 +489,7 @@
         # if its locks we are before the migrateToURI3()
         # call so no need to abortJob()
         try:
-            self._migrationCanceledEvt = True
+            self._migrationCanceledEvt.set()
             self._vm._dom.abortJob()
         except libvirt.libvirtError:
             if not self._preparingMigrationEvt:


-- 
To view, visit https://gerrit.ovirt.org/55742
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic638f67ecf311be0b81d1a7a1afe227e45f816d1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <mbe...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to