Set backup available after verify
In backup import request, the backup is set to available before it is verified. Then if the verification failed, the backup's status is set to error. This leads to an unreasonble status change: creating -> available -> error. The available status should be set after the verification when all work is done. And the status change should be like: creating -> available, or creating -> error Closes-bug: #1669628 Change-Id: I67f30df8a8112c953f24f6d2f7d5152416d4f0df
This commit is contained in:
parent
892d5989cf
commit
dd66afbd1d
@ -764,7 +764,6 @@ class BackupManager(manager.ThreadPoolManager):
|
||||
raise exception.InvalidBackup(reason=msg)
|
||||
|
||||
# Overwrite some fields
|
||||
backup_options['status'] = fields.BackupStatus.AVAILABLE
|
||||
backup_options['service'] = self.driver_name
|
||||
backup_options['availability_zone'] = self.az
|
||||
backup_options['host'] = self.host
|
||||
@ -772,7 +771,7 @@ class BackupManager(manager.ThreadPoolManager):
|
||||
# Remove some values which are not actual fields and some that
|
||||
# were set by the API node
|
||||
for key in ('name', 'user_id', 'project_id', 'deleted_at',
|
||||
'deleted', 'fail_reason'):
|
||||
'deleted', 'fail_reason', 'status'):
|
||||
backup_options.pop(key, None)
|
||||
|
||||
# Update the database
|
||||
@ -793,6 +792,10 @@ class BackupManager(manager.ThreadPoolManager):
|
||||
with excutils.save_and_reraise_exception():
|
||||
self._update_backup_error(backup, six.text_type(err))
|
||||
|
||||
# Update the backup's status
|
||||
backup.update({"status": fields.BackupStatus.AVAILABLE})
|
||||
backup.save()
|
||||
|
||||
LOG.info(_LI('Import record id %s metadata from driver '
|
||||
'finished.'), backup.id)
|
||||
|
||||
|
@ -1227,7 +1227,13 @@ class BackupTestCaseWithVerify(BaseBackupTest):
|
||||
(backup_driver.__module__,
|
||||
backup_driver.__class__.__name__,
|
||||
'verify'))
|
||||
with mock.patch(_mock_backup_verify_class):
|
||||
|
||||
def mock_verify(backup_id):
|
||||
backup = db.backup_get(self.ctxt, backup_id)
|
||||
self.assertEqual(fields.BackupStatus.CREATING, backup['status'])
|
||||
|
||||
with mock.patch(_mock_backup_verify_class) as mock_backup_verify:
|
||||
mock_backup_verify.side_effect = mock_verify
|
||||
self.backup_mgr.import_record(self.ctxt,
|
||||
imported_record,
|
||||
export['backup_service'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user