summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYufang Zhang <yufang521247@gmail.com>2013-06-20 18:17:49 +0800
committerYufang Zhang <yufang521247@gmail.com>2013-06-21 10:22:33 +0800
commit3d27a0e74bde3878af76414dc4020ac6f9f24e4e (patch)
tree0823a6108df22b5fdaed35a9ba5ae7da01021279
parent4f863fa5f804346573a20c6b2ab17779c2b3f118 (diff)
downloadnova-3d27a0e74bde3878af76414dc4020ac6f9f24e4e.tar.gz
nova-3d27a0e74bde3878af76414dc4020ac6f9f24e4e.tar.xz
nova-3d27a0e74bde3878af76414dc4020ac6f9f24e4e.zip
Handle NoMoreFixedIps in _shutdown_instance.
Bug 1192893 If no fixed ips is found, continue to perform the rest of the instance shutdown, instead of propogating the exception. Steps to reproduce: 1. Create a network 2. Reserve all fixed ips of the network 3. Try to create an instance but failed 4. Try to delete the instance Results: Cannot delete the instance due to the 'NoMoreFixedIps' exception. Change-Id: I42776c427773f1f81c16062a9aaa54850ec68bfd
-rwxr-xr-xnova/compute/manager.py2
-rw-r--r--nova/tests/compute/test_compute.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 1def5b069..bd4e6f772 100755
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1344,7 +1344,7 @@ class ComputeManager(manager.SchedulerDependentManager):
# get network info before tearing down
try:
network_info = self._get_instance_nw_info(context, instance)
- except exception.NetworkNotFound:
+ except (exception.NetworkNotFound, exception.NoMoreFixedIps):
network_info = network_model.NetworkInfo()
# NOTE(vish) get bdms before destroying the instance
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 8c6fce3a5..abb4d8e39 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1214,6 +1214,30 @@ class ComputeTestCase(BaseTestCase):
LOG.info(_("After terminating instances: %s"), instances)
self.assertEqual(len(instances), 0)
+ def test_terminate_no_fixed_ips(self):
+ # This is as reported in LP bug 1192893
+ instance = jsonutils.to_primitive(self._create_fake_instance())
+
+ self.compute.run_instance(self.context, instance=instance)
+
+ instances = db.instance_get_all(self.context)
+ LOG.info(_("Running instances: %s"), instances)
+ self.assertEqual(len(instances), 1)
+
+ self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
+ self.compute._get_instance_nw_info(
+ mox.IgnoreArg(),
+ mox.IgnoreArg()).AndRaise(
+ exception.NoMoreFixedIps()
+ )
+ self.mox.ReplayAll()
+
+ self.compute.terminate_instance(self.context, instance=instance)
+
+ instances = db.instance_get_all(self.context)
+ LOG.info(_("After terminating instances: %s"), instances)
+ self.assertEqual(len(instances), 0)
+
def test_terminate_failure_leaves_task_state(self):
"""Ensure that a failure in terminate_instance does not result
in the task state being reverted from DELETING (see LP 1046236).