Add details of volume backup failed reason

Set the failed reason details when snapshot failed for
cinder volume, then user can get the worth information to
know why the snapshot failed.

Change-Id: I1001c41550e5147b96df0846180b587b3c3849cd
Closes-Bug: #1448820
This commit is contained in:
huangtianhua 2015-04-27 10:08:43 +08:00
parent d78c6a6e90
commit 3cff77bef3
2 changed files with 4 additions and 3 deletions

View File

@ -314,7 +314,7 @@ class CinderVolume(aws_vol.Volume):
if backup.status == 'available':
self.data_set('backup_id', backup_id)
return True
raise exception.Error(backup.status)
raise exception.Error(backup.fail_reason)
def handle_delete_snapshot(self, snapshot):
backup_id = snapshot['resource_data']['backup_id']

View File

@ -630,8 +630,9 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
self.m.StubOutWithMock(self.cinder_fc.backups, 'create')
self.cinder_fc.backups.create(fv.id).AndReturn(fb)
self.m.StubOutWithMock(self.cinder_fc.backups, 'get')
fail_reason = 'Could not determine which Swift endpoint to use'
self.cinder_fc.backups.get(fb.id).AndReturn(
vt_base.FakeBackup('error'))
vt_base.FakeBackup('error', fail_reason=fail_reason))
self.m.ReplayAll()
@ -645,7 +646,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
scheduler.TaskRunner(rsrc.snapshot))
self.assertEqual((rsrc.SNAPSHOT, rsrc.FAILED), rsrc.state)
self.assertEqual("Error: error", rsrc.status_reason)
self.assertIn(fail_reason, rsrc.status_reason)
self.assertEqual({}, resource_data_object.ResourceData.get_all(rsrc))