Remove node from cache after it scheduled

If a node is selected by an instance, we should remove it
from cache, in case of other nodes select it again, as our
node cache isn't updated immediately.

Change-Id: I9827ffb370d933cc17e7557037b3f42342fae9d0
This commit is contained in:
Zhenguo Niu 2016-12-12 21:31:16 +08:00
parent b28055beb9
commit 49e32319f5
3 changed files with 5 additions and 3 deletions

View File

@ -188,7 +188,8 @@ class EngineManager(base_manager.BaseEngineManager):
raise exception.NoValidNode(
_('No valid node is found with request spec %s') %
request_spec)
instance.node_uuid = top_node.to_dict()['node']
instance.node_uuid = top_node
del self.node_cache[top_node]
ironic.set_instance_info(self.ironicclient, instance)
# validate we are ready to do the deploy

View File

@ -187,4 +187,4 @@ class FilterScheduler(driver.Scheduler):
top_node = weighed_nodes[0]
node_state = top_node.obj
LOG.debug("Choosing %s", node_state.node)
return top_node
return node_state.node

View File

@ -61,7 +61,7 @@ class ManageInstanceTestCase(mgr_utils.ServiceSetUpMixin,
fake_type = db_utils.get_test_instance_type(context=self.context)
fake_type['extra_specs'] = {}
inst_type = objects.InstanceType(self.context, **fake_type)
schedule_mock.side_effect = None
schedule_mock.return_value = 'fake-node'
set_inst_mock.side_effect = None
validate_mock.side_effect = None
build_net_mock.side_effect = None
@ -70,6 +70,7 @@ class ManageInstanceTestCase(mgr_utils.ServiceSetUpMixin,
requested_net = [{'uuid': 'fake-net-uuid'}]
self._start_service()
self.service.node_cache = {'fake-node': 'node'}
self.service.create_instance(self.context, instance,
requested_net, inst_type)
self._stop_service()