Merge "Target cell on local delete"
This commit is contained in:
commit
11ad2da58b
@ -1839,6 +1839,7 @@ class API(base.Base):
|
|||||||
instance=instance)
|
instance=instance)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
cell = None
|
||||||
# If there is an instance.host (or the instance is shelved-offloaded),
|
# If there is an instance.host (or the instance is shelved-offloaded),
|
||||||
# the instance has been scheduled and sent to a cell/compute which
|
# the instance has been scheduled and sent to a cell/compute which
|
||||||
# means it was pulled from the cell db.
|
# means it was pulled from the cell db.
|
||||||
@ -2024,8 +2025,23 @@ class API(base.Base):
|
|||||||
# If instance is in shelved_offloaded state or compute node
|
# If instance is in shelved_offloaded state or compute node
|
||||||
# isn't up, delete instance from db and clean bdms info and
|
# isn't up, delete instance from db and clean bdms info and
|
||||||
# network info
|
# network info
|
||||||
self._local_delete(context, instance, bdms, delete_type, cb)
|
if cell is None:
|
||||||
quotas.commit()
|
# NOTE(danms): If we didn't get our cell from one of the
|
||||||
|
# paths above, look it up now.
|
||||||
|
try:
|
||||||
|
im = objects.InstanceMapping.get_by_instance_uuid(
|
||||||
|
context, instance.uuid)
|
||||||
|
cell = im.cell_mapping
|
||||||
|
except exception.InstanceMappingNotFound:
|
||||||
|
LOG.warning('During local delete, failed to find '
|
||||||
|
'instance mapping', instance=instance)
|
||||||
|
return
|
||||||
|
|
||||||
|
LOG.debug('Doing local delete in cell %s', cell.identity,
|
||||||
|
instance=instance)
|
||||||
|
with nova_context.target_cell(context, cell) as cctxt:
|
||||||
|
self._local_delete(cctxt, instance, bdms, delete_type, cb)
|
||||||
|
quotas.commit()
|
||||||
|
|
||||||
except exception.InstanceNotFound:
|
except exception.InstanceNotFound:
|
||||||
# NOTE(comstud): Race condition. Instance already gone.
|
# NOTE(comstud): Race condition. Instance already gone.
|
||||||
|
@ -840,6 +840,12 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
self.compute_api.notifier,
|
self.compute_api.notifier,
|
||||||
self.context, inst, '%s.end' % delete_type,
|
self.context, inst, '%s.end' % delete_type,
|
||||||
system_metadata=inst.system_metadata)
|
system_metadata=inst.system_metadata)
|
||||||
|
cell = objects.CellMapping(uuid=uuids.cell,
|
||||||
|
transport_url='fake://',
|
||||||
|
database_connection='fake://')
|
||||||
|
im = objects.InstanceMapping(cell_mapping=cell)
|
||||||
|
objects.InstanceMapping.get_by_instance_uuid(
|
||||||
|
self.context, inst.uuid).AndReturn(im)
|
||||||
|
|
||||||
def _test_delete(self, delete_type, **attrs):
|
def _test_delete(self, delete_type, **attrs):
|
||||||
reservations = ['fake-resv']
|
reservations = ['fake-resv']
|
||||||
@ -883,6 +889,9 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
self.mox.StubOutWithMock(rpcapi, 'confirm_resize')
|
self.mox.StubOutWithMock(rpcapi, 'confirm_resize')
|
||||||
self.mox.StubOutWithMock(self.compute_api.consoleauth_rpcapi,
|
self.mox.StubOutWithMock(self.compute_api.consoleauth_rpcapi,
|
||||||
'delete_tokens_for_instance')
|
'delete_tokens_for_instance')
|
||||||
|
self.mox.StubOutWithMock(objects.InstanceMapping,
|
||||||
|
'get_by_instance_uuid')
|
||||||
|
|
||||||
if (inst.vm_state in
|
if (inst.vm_state in
|
||||||
(vm_states.SHELVED, vm_states.SHELVED_OFFLOADED)):
|
(vm_states.SHELVED, vm_states.SHELVED_OFFLOADED)):
|
||||||
self._test_delete_shelved_part(inst)
|
self._test_delete_shelved_part(inst)
|
||||||
|
Loading…
Reference in New Issue
Block a user