Merge "Clean uploading volume when c-vol restarts"
This commit is contained in:
commit
d5ccbf9c28
@ -285,6 +285,27 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
self.assertEqual("error", volume['status'])
|
||||
self.volume.delete_volume(self.context, volume_id)
|
||||
|
||||
def test_init_host_clears_uploads_available_volume(self):
|
||||
"""init_host will clean an available volume stuck in uploading."""
|
||||
volume = tests_utils.create_volume(self.context, status='uploading',
|
||||
size=0, host=CONF.host)
|
||||
self.volume.init_host()
|
||||
volume = objects.Volume.get_by_id(context.get_admin_context(),
|
||||
volume.id)
|
||||
self.assertEqual("available", volume.status)
|
||||
|
||||
def test_init_host_clears_uploads_in_use_volume(self):
|
||||
"""init_host will clean an in-use volume stuck in uploading."""
|
||||
volume = tests_utils.create_volume(self.context, status='uploading',
|
||||
size=0, host=CONF.host)
|
||||
fake_uuid = fakes.get_fake_uuid()
|
||||
tests_utils.attach_volume(self.context, volume.id, fake_uuid,
|
||||
'fake_host', '/dev/vda')
|
||||
self.volume.init_host()
|
||||
volume = objects.Volume.get_by_id(context.get_admin_context(),
|
||||
volume.id)
|
||||
self.assertEqual("in-use", volume.status)
|
||||
|
||||
def test_init_host_resumes_deletes(self):
|
||||
"""init_host will resume deleting volume in deleting status."""
|
||||
volume = tests_utils.create_volume(self.context, status='deleting',
|
||||
|
@ -424,6 +424,10 @@ class VolumeManager(manager.SchedulerDependentManager):
|
||||
self.driver.clear_download(ctxt, volume)
|
||||
volume.status = 'error'
|
||||
volume.save()
|
||||
elif volume.status == 'uploading':
|
||||
# Set volume status to available or in-use.
|
||||
self.db.volume_update_status_based_on_attachment(
|
||||
ctxt, volume.id)
|
||||
else:
|
||||
pass
|
||||
snapshots = objects.SnapshotList.get_by_host(
|
||||
|
Loading…
Reference in New Issue
Block a user