Răsfoiți Sursa

Start replica instance shutdown task after `GET_INFO` task.

Considering the `SHUTDOWN_INSTANCE` task should *not* alter the state of
the VM (and thus the instance's info), we should shutdown the VM only
after fetching its info in case there are platforms where shutting down
the VM loses information (ex: some vShere deployments auto-flush the
guest IP info if the VM is shut off)
Nashwan Azhari 8 ani în urmă
părinte
comite
c08eac70d8
1 a modificat fișierele cu 35 adăugiri și 35 ștergeri
  1. 35 35
      coriolis/conductor/rpc/server.py

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

@@ -230,48 +230,48 @@ class ConductorServerEndpoint(object):
         execution.action = replica
 
         for instance in execution.action.instances:
-                depends_on = []
-                if shutdown_instances:
-                    shutdown_instance_task = self._create_task(
-                        instance, constants.TASK_TYPE_SHUTDOWN_INSTANCE,
-                        execution)
-                    depends_on = [shutdown_instance_task.id]
-
-                get_instance_info_task = self._create_task(
-                    instance, constants.TASK_TYPE_GET_INSTANCE_INFO,
+            get_instance_info_task = self._create_task(
+                instance, constants.TASK_TYPE_GET_INSTANCE_INFO,
+                execution)
+
+            depends_on = [get_instance_info_task.id]
+            if shutdown_instances:
+                shutdown_instance_task = self._create_task(
+                    instance, constants.TASK_TYPE_SHUTDOWN_INSTANCE,
                     execution, depends_on=depends_on)
+                depends_on = [shutdown_instance_task.id]
 
-                deploy_replica_disks_task = self._create_task(
-                    instance, constants.TASK_TYPE_DEPLOY_REPLICA_DISKS,
-                    execution, depends_on=[get_instance_info_task.id])
+            deploy_replica_disks_task = self._create_task(
+                instance, constants.TASK_TYPE_DEPLOY_REPLICA_DISKS,
+                execution, depends_on=depends_on)
 
-                deploy_replica_source_resources_task = self._create_task(
-                    instance,
-                    constants.TASK_TYPE_DEPLOY_REPLICA_SOURCE_RESOURCES,
-                    execution, depends_on=[deploy_replica_disks_task.id])
+            deploy_replica_source_resources_task = self._create_task(
+                instance,
+                constants.TASK_TYPE_DEPLOY_REPLICA_SOURCE_RESOURCES,
+                execution, depends_on=[deploy_replica_disks_task.id])
 
-                deploy_replica_target_resources_task = self._create_task(
-                    instance,
-                    constants.TASK_TYPE_DEPLOY_REPLICA_TARGET_RESOURCES,
-                    execution, depends_on=[deploy_replica_disks_task.id])
+            deploy_replica_target_resources_task = self._create_task(
+                instance,
+                constants.TASK_TYPE_DEPLOY_REPLICA_TARGET_RESOURCES,
+                execution, depends_on=[deploy_replica_disks_task.id])
 
-                replicate_disks_task = self._create_task(
-                    instance, constants.TASK_TYPE_REPLICATE_DISKS,
-                    execution, depends_on=[
-                        deploy_replica_source_resources_task.id,
-                        deploy_replica_target_resources_task.id])
+            replicate_disks_task = self._create_task(
+                instance, constants.TASK_TYPE_REPLICATE_DISKS,
+                execution, depends_on=[
+                    deploy_replica_source_resources_task.id,
+                    deploy_replica_target_resources_task.id])
 
-                self._create_task(
-                    instance,
-                    constants.TASK_TYPE_DELETE_REPLICA_SOURCE_RESOURCES,
-                    execution, depends_on=[replicate_disks_task.id],
-                    on_error=True)
+            self._create_task(
+                instance,
+                constants.TASK_TYPE_DELETE_REPLICA_SOURCE_RESOURCES,
+                execution, depends_on=[replicate_disks_task.id],
+                on_error=True)
 
-                self._create_task(
-                    instance,
-                    constants.TASK_TYPE_DELETE_REPLICA_TARGET_RESOURCES,
-                    execution, depends_on=[replicate_disks_task.id],
-                    on_error=True)
+            self._create_task(
+                instance,
+                constants.TASK_TYPE_DELETE_REPLICA_TARGET_RESOURCES,
+                execution, depends_on=[replicate_disks_task.id],
+                on_error=True)
 
         db_api.add_replica_tasks_execution(ctxt, execution)
         LOG.info("Replica tasks execution created: %s", execution.id)