summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2017-04-05 16:27:41 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2017-04-06 21:35:04 -0400
commit6384e935be147d3f454c264703136c5e82eebafd (patch)
treeb23be824b39532a13b4a80d810d7e906f107ecf3
parent2b66c6780a9bb12afcbe59b2502e01258498032e (diff)
downloadnova-6384e935be147d3f454c264703136c5e82eebafd.tar.gz
Perform old-style local delete for shelved offloaded instances
This fixes a regression from some local delete code added for cells v2 where it assumed that if an instance did not have a host, it wasn't scheduled to a cell yet. That assumption misses the fact that the instance won't have a host if it was shelved offloaded. And to be shelved offloaded, the instance had to have first been built on a host in a cell. So we simply duplicate the same check as later in the _delete() method for instance.host or shelved-offloaded to decide what the case is. Obviously this is all a giant mess of duplicate delete path code that needs to be unwound, and that's the plan, but first we're fixing regressions and then we can start rolling this duplication all back so we can get back to the single local delete flow that we know and love. Change-Id: Ie2063f621618c1d90aeb59f0f1d7da351862ea9f Closes-Bug: #1678326 (cherry picked from commit 9245bbf79ddbfd8a2e2310af654711f9d3a547b1)
-rw-r--r--nova/compute/api.py8
-rw-r--r--nova/tests/functional/regressions/test_bug_1675570.py6
2 files changed, 9 insertions, 5 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 210e652f59..4585381d7e 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1771,10 +1771,12 @@ class API(base.Base):
instance=instance)
return
- # If there is an instance.host the instance has been scheduled and
- # sent to a cell/compute which means it was pulled from the cell db.
+ # If there is an instance.host (or the instance is shelved-offloaded),
+ # the instance has been scheduled and sent to a cell/compute which
+ # means it was pulled from the cell db.
# Normal delete should be attempted.
- if not instance.host:
+ if not (instance.host or
+ instance.vm_state == vm_states.SHELVED_OFFLOADED):
try:
if self._delete_while_booting(context, instance):
return
diff --git a/nova/tests/functional/regressions/test_bug_1675570.py b/nova/tests/functional/regressions/test_bug_1675570.py
index c2c194af22..51a550621e 100644
--- a/nova/tests/functional/regressions/test_bug_1675570.py
+++ b/nova/tests/functional/regressions/test_bug_1675570.py
@@ -64,6 +64,8 @@ class TestLocalDeleteAttachedVolumes(test.TestCase):
self.flags(driver='chance_scheduler', group='scheduler')
self.start_service('scheduler')
self.start_service('compute')
+ # The consoleauth service is needed for deleting console tokens.
+ self.start_service('consoleauth')
self.useFixture(cast_as_call.CastAsCall(self.stubs))
@@ -164,5 +166,5 @@ class TestLocalDeleteAttachedVolumes(test.TestCase):
LOG.info('Validating that volume %s was detached from server %s.',
volume_id, server_id)
- # When bug 1675570 is fixed, this should be assertNotIn.
- self.assertIn(volume_id, self.cinder.attachments[server_id])
+ # Now that the bug is fixed, assert the volume was detached.
+ self.assertNotIn(volume_id, self.cinder.attachments[server_id])