Просмотр исходного кода

Make minion machine allocation to action asynchronous.

Nashwan Azhari 5 лет назад
Родитель
Сommit
e8022a6e22

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

@@ -1521,13 +1521,29 @@ class ConductorServerEndpoint(object):
             include_osmorphing_minions=include_osmorphing_minions)
 
     def _deallocate_minion_machines_for_action(self, ctxt, action):
+        # NOTE: we only send the required info for deallocation to avoid
+        # extraneous background loads from the DB of uneeded attributes
+        action_deallocation_info = {
+            "id": action.base_id,
+            "instances": action.instances,
+            "origin_minion_pool_id": action.origin_minion_pool_id,
+            "destination_minion_pool_id": action.destination_minion_pool_id,
+            "instance_osmorphing_minion_pool_mappings": (
+                action.instance_osmorphing_minion_pool_mappings)}
         return self._minion_manager_client.deallocate_minion_machines_for_action(
-            ctxt, action)
+            ctxt, action_deallocation_info)
 
     def _check_minion_pools_for_action(self, ctxt, action):
         return self._minion_manager_client.validate_minion_pool_selections_for_action(
             ctxt, action)
 
+    def accept_minion_allocations_for_execution(
+            self, ctxt, execution_id, action_id, pool_allocations):
+        # TODO: fetch execution
+        # update action_info
+        # call begin_tasks
+        pass
+
     def migrate_instances(self, ctxt, origin_endpoint_id,
                           destination_endpoint_id, origin_minion_pool_id,
                           destination_minion_pool_id,

+ 0 - 2
coriolis/constants.py

@@ -333,7 +333,6 @@ MINION_POOL_MACHINE_RETENTION_STRATEGY_POWEROFF = "poweroff"
 
 MINION_POOL_STATUS_UNKNOWN = "UNKNOWN"
 MINION_POOL_STATUS_ERROR = "ERROR"
-MINION_POOL_STATUS_UNINITIALIZED = "UNINITIALIZED"
 MINION_POOL_STATUS_DEALLOCATED = "DEALLOCATED"
 MINION_POOL_STATUS_VALIDATING_INPUTS = "VALIDATING_INPUTS"
 MINION_POOL_STATUS_ALLOCATING_SHARED_RESOURCES = "ALLOCATING_SHARED_RESOURCES"
@@ -356,7 +355,6 @@ MINION_MACHINE_STATUS_UNKNOWN = "UNKNOWN"
 MINION_MACHINE_STATUS_DEPLOYING = "DEPLOYING"
 MINION_MACHINE_STATUS_ERROR = "ERROR"
 MINION_MACHINE_STATUS_ERROR_DEPLOYING = "ERROR_DEPLOYING"
-MINION_MACHINE_STATUS_UNINITIALIZED = "UNINITIALIZED"
 MINION_MACHINE_STATUS_RECONFIGURING = "RECONFIGURING"
 MINION_MACHINE_STATUS_AVAILABLE = "AVAILABLE"
 MINION_MACHINE_STATUS_ALLOCATED = "ALLOCATED"

+ 2 - 2
coriolis/minion_manager/rpc/client.py

@@ -60,13 +60,13 @@ class MinionManagerClient(object):
     def allocate_minion_machines_for_action(
             self, ctxt, action, include_transfer_minions=True,
             include_osmorphing_minions=True):
-        return self._client.call(
+        return self._client.cast(
             ctxt, 'allocate_minion_machines_for_action', action=action,
             include_transfer_minions=include_transfer_minions,
             include_osmorphing_minions=include_osmorphing_minions)
 
     def deallocate_minion_machines_for_action(self, ctxt, action):
-        return self._client.call(
+        return self._client.cast(
             ctxt, 'deallocate_minion_machines_for_action', action=action)
 
     def create_minion_pool(

+ 9 - 6
coriolis/minion_manager/rpc/server.py

@@ -731,7 +731,7 @@ class MinionManagerServerEndpoint(object):
         minion_pool.os_type = pool_os_type
         minion_pool.endpoint_id = endpoint_id
         minion_pool.environment_options = environment_options
-        minion_pool.status = constants.MINION_POOL_STATUS_UNINITIALIZED
+        minion_pool.status = constants.MINION_POOL_STATUS_DEALLOCATED
         minion_pool.minimum_minions = minimum_minions
         minion_pool.maximum_minions = maximum_minions
         minion_pool.minion_max_idle_time = minion_max_idle_time
@@ -780,6 +780,7 @@ class MinionManagerServerEndpoint(object):
                 include_events=False, include_progress_updates=False)
         unused_machine_states = [
             constants.MINION_MACHINE_STATUS_AVAILABLE,
+            constants.MINION_MACHINE_STATUS_ERROR_DEPLOYING,
             constants.MINION_MACHINE_STATUS_ERROR]
         used_machines = {
             mch for mch in minion_pool.minion_machines
@@ -801,7 +802,6 @@ class MinionManagerServerEndpoint(object):
         endpoint_dict = self._conductor_client.get_endpoint(
             ctxt, minion_pool.endpoint_id)
         acceptable_allocation_statuses = [
-            constants.MINION_POOL_STATUS_UNINITIALIZED,
             constants.MINION_POOL_STATUS_DEALLOCATED]
         current_status = minion_pool.status
         if current_status not in acceptable_allocation_statuses:
@@ -892,9 +892,13 @@ class MinionManagerServerEndpoint(object):
             ctxt, minion_pool_id, include_events=False, include_machines=True,
             include_progress_updates=False)
         current_status = minion_pool.status
+        if current_status == constants.MINION_POOL_STATUS_DEALLOCATED:
+            LOG.debug(
+                "Deallocation requested on already deallocated pool '%s'. "
+                "Nothing to do so returning early.", minion_pool_id)
+            return self._get_minion_pool(ctxt, minion_pool.id)
         acceptable_deallocation_statuses = [
             constants.MINION_POOL_STATUS_ALLOCATED,
-            constants.MINION_POOL_STATUS_UNINITIALIZED,
             constants.MINION_POOL_STATUS_ERROR]
         if current_status not in acceptable_deallocation_statuses:
             if not force:
@@ -1235,14 +1239,14 @@ class MinionManagerServerEndpoint(object):
     def update_minion_pool(self, ctxt, minion_pool_id, updated_values):
         minion_pool = self._get_minion_pool(
             ctxt, minion_pool_id, include_machines=False)
-        if minion_pool.status != constants.MINION_POOL_STATUS_UNINITIALIZED:
+        if minion_pool.status != constants.MINION_POOL_STATUS_DEALLOCATED:
             raise exception.InvalidMinionPoolState(
                 "Minion Pool '%s' cannot be updated as it is in '%s' status "
                 "instead of the expected '%s'. Please ensure the pool machines"
                 "have been deallocated and the pool's supporting resources "
                 "have been torn down before updating the pool." % (
                     minion_pool_id, minion_pool.status,
-                    constants.MINION_POOL_STATUS_UNINITIALIZED))
+                    constants.MINION_POOL_STATUS_DEALLOCATED))
         LOG.info(
             "Attempting to update minion_pool '%s' with payload: %s",
             minion_pool_id, updated_values)
@@ -1256,7 +1260,6 @@ class MinionManagerServerEndpoint(object):
             ctxt, minion_pool_id, include_machines=True)
         acceptable_deletion_statuses = [
             constants.MINION_POOL_STATUS_DEALLOCATED,
-            constants.MINION_POOL_STATUS_UNINITIALIZED,
             constants.MINION_POOL_STATUS_ERROR]
         if minion_pool.status not in acceptable_deletion_statuses:
             raise exception.InvalidMinionPoolState(