From 5199d96aa2e8fd864299bbe67ff8920812a802b7 Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Sat, 25 Mar 2017 16:14:49 +0800 Subject: [PATCH] Move retry information setting from scheduler to engine As we already splitted scheduler out from engine service, the retry information can't be saved anymore, so move the logic to engine to make it work again. Change-Id: If0ddc339ea705889fc52a84ed190df136abca650 --- mogan/engine/manager.py | 15 +++++++++++++++ mogan/scheduler/filter_scheduler.py | 23 ----------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/mogan/engine/manager.py b/mogan/engine/manager.py index 95ade4bc..47156413 100644 --- a/mogan/engine/manager.py +++ b/mogan/engine/manager.py @@ -313,11 +313,26 @@ class EngineManager(base_manager.BaseEngineManager): if filter_properties is None: filter_properties = {} + retry = filter_properties.pop('retry', {}) + + # update attempt count: + if retry: + retry['num_attempts'] += 1 + else: + retry = { + 'num_attempts': 1, + 'nodes': [] # list of tried nodes + } + filter_properties['retry'] = retry + try: node = self.scheduler_rpcapi.select_destinations( context, request_spec, filter_properties) instance.node_uuid = node['node_uuid'] instance.save() + # Add a retry entry for the selected node + nodes = retry['nodes'] + nodes.append(node['node_uuid']) except Exception as e: utils.process_event(fsm, instance, event='error') LOG.error("Created instance %(uuid)s failed. " diff --git a/mogan/scheduler/filter_scheduler.py b/mogan/scheduler/filter_scheduler.py index 21d99411..648dd49e 100644 --- a/mogan/scheduler/filter_scheduler.py +++ b/mogan/scheduler/filter_scheduler.py @@ -50,18 +50,6 @@ class FilterScheduler(driver.Scheduler): filter_properties['availability_zone'] = \ instance.get('availability_zone') - def _add_retry_node(self, filter_properties, node): - """Add a retry entry for the selected Ironic node. - - In the event that the request gets re-scheduled, this entry will signal - that the given node has already been tried. - """ - retry = filter_properties.get('retry', None) - if not retry: - return - nodes = retry['nodes'] - nodes.append(node) - def _max_attempts(self): max_attempts = CONF.scheduler.scheduler_max_attempts if max_attempts < 1: @@ -99,16 +87,6 @@ class FilterScheduler(driver.Scheduler): # re-scheduling is disabled. return - # retry is enabled, update attempt count: - if retry: - retry['num_attempts'] += 1 - else: - retry = { - 'num_attempts': 1, - 'nodes': [] # list of Ironic nodes tried - } - filter_properties['retry'] = retry - instance_id = request_spec.get('instance_id') self._log_instance_error(instance_id, retry) @@ -187,7 +165,6 @@ class FilterScheduler(driver.Scheduler): node = self._choose_top_node(weighed_nodes, request_spec) node.obj.consume_from_request(context) - self._add_retry_node(filter_properties, node.obj.node_uuid) dest = dict(node_uuid=node.obj.node_uuid, ports=node.obj.ports) return dest