Fixed quotas double decreasing problem
When we delete vm with status "soft-delete" we shouldn't change quota values because they were changed during soft-deleting. Closes-bug: #1333145 Change-Id: I3ed7b3245b8908faa02903c74503918f061016bd
This commit is contained in:
parent
d9d04933a4
commit
4546ce0012
|
@ -1615,6 +1615,14 @@ class API(base.Base):
|
|||
self._record_action_start(context, instance,
|
||||
instance_actions.DELETE)
|
||||
|
||||
# NOTE(snikitin): If instance's vm_state is 'soft-delete',
|
||||
# we should not count reservations here, because instance
|
||||
# in soft-delete vm_state have already had quotas
|
||||
# decremented. More details:
|
||||
# https://bugs.launchpad.net/nova/+bug/1333145
|
||||
if instance['vm_state'] == vm_states.SOFT_DELETED:
|
||||
quotas.rollback()
|
||||
|
||||
cb(context, instance, bdms,
|
||||
reservations=quotas.reservations)
|
||||
except exception.ComputeHostNotFound:
|
||||
|
|
|
@ -672,10 +672,12 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
|
||||
cast = True
|
||||
commit_quotas = True
|
||||
soft_delete = False
|
||||
if self.cell_type != 'api':
|
||||
if inst.vm_state == vm_states.RESIZED:
|
||||
self._test_delete_resized_part(inst)
|
||||
|
||||
if inst.vm_state == vm_states.SOFT_DELETED:
|
||||
soft_delete = True
|
||||
self.context.elevated().AndReturn(self.context)
|
||||
db.service_get_by_compute_host(
|
||||
self.context, inst.host).AndReturn(
|
||||
|
@ -696,7 +698,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
if self.cell_type != 'api':
|
||||
self.compute_api._record_action_start(self.context, inst,
|
||||
instance_actions.DELETE)
|
||||
if commit_quotas:
|
||||
if commit_quotas or soft_delete:
|
||||
cast_reservations = None
|
||||
else:
|
||||
cast_reservations = reservations
|
||||
|
|
Loading…
Reference in New Issue