]> xenbits.xensource.com Git - osstest/openstack-nova.git/commitdiff
Perform old-style local delete for shelved offloaded instances
authorMatt Riedemann <mriedem.os@gmail.com>
Wed, 5 Apr 2017 20:27:41 +0000 (16:27 -0400)
committerMatt Riedemann <mriedem.os@gmail.com>
Fri, 7 Apr 2017 01:35:04 +0000 (21:35 -0400)
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)

nova/compute/api.py
nova/tests/functional/regressions/test_bug_1675570.py

index 210e652f59b4272f5befee65157298cf5b3240c9..4585381d7e00f8e9a1ba37f50f60a25bcbd7b279 100644 (file)
@@ -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
index c2c194af22aeeb983d898e29385750bc62542950..51a550621ef8e41049f7dd55430b957a36e0d1e4 100644 (file)
@@ -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])