summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-09-21 13:51:15 -0400
committerRussell Bryant <rbryant@redhat.com>2012-09-21 14:35:10 -0400
commit75fa03557fd6f1e7c62079e9e89556f1af139202 (patch)
treec029f610a94b06d75c7cfd098642cbbf8c1b7afb
parentb8b048166db93f4634eca372e00f36d5ac5741bb (diff)
downloadnova-75fa03557fd6f1e7c62079e9e89556f1af139202.tar.gz
nova-75fa03557fd6f1e7c62079e9e89556f1af139202.tar.xz
nova-75fa03557fd6f1e7c62079e9e89556f1af139202.zip
Set volume status to error if scheduling fails.
Fix bug 1053931. When scheduling volume creation fails, the volume was left with a status of 'creating'. This patch changes the scheduler manager to set the status to 'error' if scheduling fails. This matches the behavior of the cinder scheduler manager in this case. This particular issue was addressed in Cinder as a part of commit f758bde47439be52a743b2b4181d4900f2c1bc8a. Change-Id: Ieb453ab05b3b84de53f72323c536a9567555df1e
-rw-r--r--nova/scheduler/manager.py6
-rw-r--r--nova/tests/scheduler/test_scheduler.py12
2 files changed, 15 insertions, 3 deletions
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index feffb584b..824dc9eb0 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -76,9 +76,9 @@ class SchedulerManager(manager.Manager):
context, volume_id, snapshot_id, image_id)
except Exception as ex:
with excutils.save_and_reraise_exception():
- self._set_vm_state_and_notify('create_volume',
- {'vm_state': vm_states.ERROR},
- context, ex, {})
+ LOG.warning(_("Failed to schedule create_volume: %(ex)s") %
+ locals())
+ db.volume_update(context, volume_id, {'status': 'error'})
def live_migration(self, context, instance, dest,
block_migration, disk_over_commit):
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py
index 3c4a789b6..83e9cffc8 100644
--- a/nova/tests/scheduler/test_scheduler.py
+++ b/nova/tests/scheduler/test_scheduler.py
@@ -175,6 +175,18 @@ class SchedulerManagerTestCase(test.TestCase):
self.manager.run_instance(self.context, request_spec,
None, None, None, None, {})
+ def test_create_volume_no_valid_host_puts_volume_in_error(self):
+ self._mox_schedule_method_helper('schedule_create_volume')
+ self.mox.StubOutWithMock(db, 'volume_update')
+
+ self.manager.driver.schedule_create_volume(self.context, '1', '2',
+ None).AndRaise(exception.NoValidHost(reason=''))
+ db.volume_update(self.context, '1', {'status': 'error'})
+
+ self.mox.ReplayAll()
+ self.assertRaises(exception.NoValidHost, self.manager.create_volume,
+ self.context, '1', '2')
+
def test_prep_resize_no_valid_host_back_in_active_state(self):
fake_instance_uuid = 'fake-instance-id'
inst = {"vm_state": "", "task_state": ""}