Fix various cells issues due to object changes
1) Child cell scheduling fails. The change to use Instance.create() in child cells broke things. The instance properties was being overwritten due to a typo. I also found a number of other things that need to be popped out before passing to create_db_entry_for_new_instance(). 2) Notification to the API cell was failing. We cannot pass an object to instance_update_at_top(). 3) When cells is enabled, deleting an instance hits the '_local_delete' part of code in the API because we don't see the compute node. There's a trap in cells_api.py to forward the delete on to child cells, but we need to make sure not to try to deallocate network in the API cell. Fixes bug 1216113 Change-Id: Ie989c22cb3b6a1359a0540e60e06fa4153e93476
This commit is contained in:
@@ -31,8 +31,8 @@ from nova.compute import vm_states
|
||||
from nova import conductor
|
||||
from nova.db import base
|
||||
from nova import exception
|
||||
from nova.objects import base as obj_base
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import security_group
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.scheduler import rpcapi as scheduler_rpcapi
|
||||
@@ -93,10 +93,12 @@ class CellsScheduler(base.Base):
|
||||
# down.
|
||||
sys_metadata = flavors.save_flavor_info(sys_metadata, instance_type)
|
||||
instance_values['system_metadata'] = sys_metadata
|
||||
# Pop out things that will get set properly when re-creating the
|
||||
# instance record.
|
||||
instance_values.pop('id')
|
||||
instance_values.pop('name')
|
||||
if 'security_groups' in instance_values:
|
||||
instance_values = security_group.make_secgroup_list(
|
||||
instance_values['security_groups'])
|
||||
instance_values.pop('info_cache')
|
||||
instance_values.pop('security_groups')
|
||||
|
||||
num_instances = len(instance_uuids)
|
||||
for i, instance_uuid in enumerate(instance_uuids):
|
||||
@@ -112,6 +114,7 @@ class CellsScheduler(base.Base):
|
||||
block_device_mapping,
|
||||
num_instances, i)
|
||||
|
||||
instance = obj_base.obj_to_primitive(instance)
|
||||
self.msg_runner.instance_update_at_top(ctxt, instance)
|
||||
|
||||
def _create_action_here(self, ctxt, instance_uuids):
|
||||
|
@@ -1384,8 +1384,9 @@ class API(base.Base):
|
||||
context, instance, "%s.start" % delete_type)
|
||||
|
||||
elevated = context.elevated()
|
||||
self.network_api.deallocate_for_instance(elevated,
|
||||
instance)
|
||||
if self.cell_type != 'api':
|
||||
self.network_api.deallocate_for_instance(elevated,
|
||||
instance)
|
||||
system_meta = self.db.instance_system_metadata_get(context,
|
||||
instance_uuid)
|
||||
|
||||
|
@@ -96,7 +96,10 @@ class CellsSchedulerTestCase(test.TestCase):
|
||||
inst_type = db.flavor_get(self.ctxt, 1)
|
||||
image = {'properties': {}}
|
||||
instance_uuids = self.instance_uuids
|
||||
instance_props = {'name': 'instance-00000001',
|
||||
instance_props = {'id': 'removed',
|
||||
'security_groups': 'removed',
|
||||
'info_cache': 'removed',
|
||||
'name': 'instance-00000001',
|
||||
'hostname': 'meow',
|
||||
'display_name': 'moo',
|
||||
'image_ref': 'fake_image_ref',
|
||||
|
@@ -413,8 +413,9 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
compute_utils.notify_about_instance_usage(self.context,
|
||||
inst,
|
||||
'%s.start' % delete_type)
|
||||
self.compute_api.network_api.deallocate_for_instance(
|
||||
self.context, inst)
|
||||
if not self.is_cells:
|
||||
self.compute_api.network_api.deallocate_for_instance(
|
||||
self.context, inst)
|
||||
db.instance_system_metadata_get(self.context, inst.uuid
|
||||
).AndReturn('sys-meta')
|
||||
state = ('soft' in delete_type and vm_states.SOFT_DELETED or
|
||||
|
Reference in New Issue
Block a user