Procházet zdrojové kódy

Fixes task cancellation issue with terminated process

Alessandro Pilotti před 9 roky
rodič
revize
a131a69c1b

+ 1 - 1
coriolis/conductor/rpc/server.py

@@ -413,7 +413,7 @@ class ConductorServerEndpoint(object):
         for task in execution.tasks:
             if task.status == constants.TASK_STATUS_RUNNING:
                 self._rpc_worker_client.cancel_task(
-                    ctxt, task.host, task.process_id, force)
+                    ctxt, task.host, task.id, task.process_id, force)
                 has_running_tasks = True
             elif (task.status == constants.TASK_STATUS_PENDING and
                     not task.on_error):

+ 3 - 2
coriolis/worker/rpc/client.py

@@ -21,10 +21,11 @@ class WorkerClient(object):
             origin=origin, destination=destination, instance=instance,
             task_info=task_info)
 
-    def cancel_task(self, ctxt, server, process_id, force):
+    def cancel_task(self, ctxt, server, task_id, process_id, force):
         # Needs to be executed on the same server
         cctxt = self._client.prepare(server=server)
-        cctxt.call(ctxt, 'cancel_task', process_id=process_id, force=force)
+        cctxt.call(ctxt, 'cancel_task', task_id=task_id, process_id=process_id,
+                   force=force)
 
     def update_migration_status(self, ctxt, task_id, status):
         self._client.call(ctxt, "update_migration_status", status=status)

+ 4 - 2
coriolis/worker/rpc/server.py

@@ -75,7 +75,7 @@ class WorkerServerEndpoint(object):
             # Ignore the exception
             LOG.exception(ex)
 
-    def cancel_task(self, ctxt, process_id, force):
+    def cancel_task(self, ctxt, task_id, process_id, force):
         if not force and os.name == "nt":
             LOG.warn("Windows does not support SIGINT, performing a "
                      "forced task termination")
@@ -91,7 +91,9 @@ class WorkerServerEndpoint(object):
                 LOG.info("Sending SIGINT to process: %s", process_id)
                 p.send_signal(signal.SIGINT)
         except psutil.NoSuchProcess:
-            LOG.info("Task process not found: %s", process_id)
+            err_msg = "Task process not found: %s" % process_id
+            LOG.info(err_msg)
+            self._rpc_conductor_client.set_task_error(ctxt, task_id, err_msg)
 
     def _handle_mp_log_events(self, p, mp_log_q):
         while True: