Restore_backup: set error when volume status not matched

When volume actual_status was not equal to expected_status, the
restoring were not setting the volume to a 'error_restoring'
status, if it so happened that the actual_status was 'available',
client would be misled to think that restoring had finished. So
this patch fixes that.

Closes-Bug:#1732378

Change-Id: I74c15a99e90a24020b2f427a70f5d04376bd31af
Signed-off-by: Xiaojun Liao <xiaojunliao85@gmail.com>
This commit is contained in:
Xiaojun Liao 2017-11-15 17:11:37 +08:00
parent 69f721b399
commit 06d4ba2080
2 changed files with 4 additions and 0 deletions

View File

@ -466,6 +466,8 @@ class BackupManager(manager.ThreadPoolManager):
'actual_status': actual_status})
backup.status = fields.BackupStatus.AVAILABLE
backup.save()
self.db.volume_update(context, volume_id,
{'status': 'error_restoring'})
raise exception.InvalidVolume(reason=err)
expected_status = fields.BackupStatus.RESTORING

View File

@ -940,6 +940,8 @@ class BackupTestCase(BaseBackupTest):
backup,
vol_id)
backup = db.backup_get(self.ctxt, backup.id)
vol = db.volume_get(self.ctxt, vol_id)
self.assertEqual('error_restoring', vol['status'])
self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
def test_restore_backup_with_bad_backup_status(self):