nova/nova/compute
Matt Riedemann f8c2df78f2 Decrement quota usage when deleting an instance in cell0
When we fail to schedule an instance, e.g. there are no hosts
available, conductor creates the instance in the cell0 database
and deletes the build request. At this point quota usage
has been incremented in the main 'nova' database.

When the instance is deleted, the build request is already gone
so _delete_while_booting returns False and we lookup the instance
in cell0 and delete it from there, but that flow wasn't decrementing
quota usage like _delete_while_booting was.

This change adds the same quota usage decrement handling that
_delete_while_booting performs.

NOTE(mriedem): This change also pulls in some things from
I7de87dce216835729283bca69f0eff59a679b624 which is not being
backported to Ocata since in Pike it solves a slightly different
part of this quota usage issue. In Pike the cell mapping db_connection
is actually stored on the context object when we get the instance
from nova.compute.api.API.get(). So the fix in Pike is slightly
different from Ocata. However, what we need to pull from that Pike
change is:

1. We need to target the cell that the instance lives in to get the
   flavor information when creating the quota reservation.

2. We need to change the functional regression test to assert that
   the bug is fixed.

The code and tests are adjusted to be a sort of mix between both
changes in Pike without requiring a full backport of the 2nd
part of the fix in Pike.

Change-Id: I4cb0169ce0de537804ab9129bc671d75ce5f7953
Partial-Bug: #1670627
(cherry picked from commit 018068c4ca)
2017-03-13 18:45:12 -04:00
..
monitors Fix invalid import order 2016-07-04 11:23:52 +05:30
__init__.py Switch to using oslo_* instead of oslo.* 2015-02-06 06:03:10 -05:00
api.py Decrement quota usage when deleting an instance in cell0 2017-03-13 18:45:12 -04:00
build_results.py Compute Add build_instance hook in compute manager 2014-12-04 10:12:00 -05:00
cells_api.py Move instance creation to conductor 2017-01-26 12:02:54 -08:00
claims.py rt: use a single ResourceTracker object instance 2017-01-16 14:09:25 -05:00
flavors.py Merge "Replace flavors.get_all_flavors_sorted_list() with object call" 2016-10-18 12:13:09 +00:00
instance_actions.py Report instance-actions for live migration force complete API 2016-03-10 15:02:35 +00:00
manager.py libvirt: Remove redundant bdm serial mangling and saving during swap_volume 2017-02-09 13:36:39 +00:00
power_state.py Removed enum duplication from nova.compute 2016-09-02 07:30:44 +00:00
resource_tracker.py Avoid redundant call to update_resource_stats from RT 2017-01-27 18:23:45 +00:00
rpcapi.py Integrate OSProfiler and Nova 2017-01-18 15:00:14 +07:00
stats.py Address nits in I83a5f06ad 2016-03-09 13:19:59 +00:00
task_states.py Removed enum duplication from nova.compute 2016-09-02 07:30:44 +00:00
utils.py Fix missing instance.delete notification 2017-03-13 15:02:06 -04:00
vm_states.py Removed enum duplication from nova.compute 2016-09-02 07:30:44 +00:00