Gabriel Adrian Samfira 8 anni fa
parent
commit
77f5ac7141
2 ha cambiato i file con 13 aggiunte e 8 eliminazioni
  1. 6 7
      coriolis/migrations/manager.py
  2. 7 1
      coriolis/providers/backup_writers.py

+ 6 - 7
coriolis/migrations/manager.py

@@ -24,14 +24,13 @@ def _copy_volume(volume, backup_writer, event_manager):
     # just an identifier. We use it to create a socket path
     # that we pass to qemu-nbd
     name = str(uuid.uuid4())
-    vol_id = volume["volume_id"]
 
     with backup_writer.open("", disk_id) as writer:
         with nbd.DiskImageReader(virtual_disk, name) as reader:
             perc_step = event_manager.add_percentage_step(
                 reader.export_size,
                 message_format="Disk copy progress for %s: "
-                               "{:.0f}%%" % vol_id)
+                               "{:.0f}%%" % disk_id)
             chunk = 4096
             offset = 0
             write_offset = 0
@@ -63,11 +62,11 @@ def _copy_volume(volume, backup_writer, event_manager):
 
 
 def _copy_wrapper(job_args):
-    vol_id = job_args[0].get("volume_id")
+    disk_id = job_args[0].get("disk_id")
     try:
-        return _copy_volume(*job_args), vol_id, False
+        return _copy_volume(*job_args), disk_id, False
     except BaseException:
-        return sys.exc_info(), vol_id, True
+        return sys.exc_info(), disk_id, True
 
 
 def copy_disk_data(target_conn_info, volumes_info, event_handler):
@@ -96,12 +95,12 @@ def copy_disk_data(target_conn_info, volumes_info, event_handler):
 
     pool = eventlet.greenpool.GreenPool()
     job_data = [(vol, backup_writer, event_manager) for vol in volumes_info]
-    for result, vol_id, error in pool.imap(_copy_wrapper, job_data):
+    for result, disk_id, error in pool.imap(_copy_wrapper, job_data):
         # TODO (gsamfira): There is no use in letting the other disks finish
         # sync-ing as we don't save the state of the disk sync anywhere (yet).
         # When/If we ever do add this info to the database, keep track of
         # failures, and allow any other paralel sync to finish
         if error:
             event_manager.progress_update(
-                "Volume \"%s\" failed to sync" % vol_id)
+                "Volume \"%s\" failed to sync" % disk_id)
             raise result[0](result[1]).with_traceback(result[2])

+ 7 - 1
coriolis/providers/backup_writers.py

@@ -88,7 +88,13 @@ class SSHBackupWriter(BaseBackupWriter):
         except Exception as ex:
             LOG.exception(ex)
 
-            ret_val = self._stdout.channel.recv_exit_status()
+            ret_val = None
+            # if the application is still running on the other side,
+            # recv_exit_status() will block. Check that we have an
+            # exit status before retrieving it
+            if self._stdout.channel.exit_status_ready():
+                ret_val = self._stdout.channel.recv_exit_status()
+
             self._ssh.close()
 
             if ret_val: