Change the matching method of the backup driver
The backup driver name is configured uniformly from the Stein version. For example, support for 'cinder.backup.drivers.service.ServiceBackupDriver' does not support 'cinder.backup.drivers.service'. However, the above two backup drivers are supported in a stable version before Rocky (including Rocky). For the same storage backend, if the backup driver used to create the backup file is 'cinder.backup.drivers.service.ServiceBackupDriver', the backup driver configured when restoring the backup is 'cinder.backup.drivers.service'. The recovery of the backup file will fail because the drivers do not match. Therefore, the processing of this method needs to be compatible with the backup driver for different configurations of the same backend. The above 'service' is a proxy, it can be one of {'swift', 'nfs', 'ceph', 'glusterfs', 'google', 'tsm', 'posix'} Closes-Bug: #1801316 Change-Id: I1d7ee395c89beda0e50cbe26b4abb4fc7749e15e
This commit is contained in:
parent
43d6c50b73
commit
b90a13d07d
@ -521,11 +521,13 @@ class BackupManager(manager.ThreadPoolManager):
|
||||
if not backup:
|
||||
return True
|
||||
|
||||
# TODO(tommylikehu): We upgraded the 'driver_name' from module
|
||||
# to class name, so we use 'in' here to match two namings,
|
||||
# this can be replaced with equal sign during next
|
||||
# release (Rocky).
|
||||
if self.driver_name.startswith(backup):
|
||||
# TODO(tommylikehu): We upgraded the 'driver_name' from module to
|
||||
# class name, so we use 'startswith' here to match two namings,
|
||||
# this can be replaced with equal sign during next release (Rocky).
|
||||
# The 'driver_name' varies depending on the user settings, so a
|
||||
# two-way judgment is required.
|
||||
if self.driver_name.startswith(backup) or backup.startswith(
|
||||
self.driver_name):
|
||||
return True
|
||||
|
||||
# We support renaming of drivers, so check old names as well
|
||||
|
@ -1778,6 +1778,29 @@ class BackupTestCase(BaseBackupTest):
|
||||
self.assertEqual(100, tpool._nthreads)
|
||||
self.assertListEqual([], tpool._threads)
|
||||
|
||||
def test_driver_name_startswith_backup_service_name(self):
|
||||
service_name = 'cinder.tests.unit.backup.fake_service'
|
||||
driver_name = 'cinder.tests.unit.backup.fake_service.FakeBackupService'
|
||||
self.override_config('backup_driver', driver_name)
|
||||
vol_id = self._create_volume_db_entry(status='available', size=1)
|
||||
backup = self._create_backup_db_entry(status=fields.BackupStatus.ERROR,
|
||||
volume_id=vol_id,
|
||||
service=service_name)
|
||||
result = self.backup_mgr._is_our_backup(backup)
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_backup_service_name_startswith_driver_name(self):
|
||||
driver_name = 'cinder.tests.unit.backup.fake_service'
|
||||
service_name = ('cinder.tests.unit.backup.fake_service.'
|
||||
'FakeBackupService')
|
||||
self.override_config('backup_driver', driver_name)
|
||||
vol_id = self._create_volume_db_entry(status='available', size=1)
|
||||
backup = self._create_backup_db_entry(status=fields.BackupStatus.ERROR,
|
||||
volume_id=vol_id,
|
||||
service=service_name)
|
||||
result = self.backup_mgr._is_our_backup(backup)
|
||||
self.assertTrue(result)
|
||||
|
||||
|
||||
class BackupTestCaseWithVerify(BaseBackupTest):
|
||||
"""Test Case for backups."""
|
||||
|
Loading…
Reference in New Issue
Block a user