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
(cherry picked from commit 75fa03557f
)
This commit is contained in:
parent
d8159d0602
commit
fb1f3502da
@ -78,9 +78,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):
|
||||
|
@ -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": ""}
|
||||
|
Loading…
Reference in New Issue
Block a user