Fix retype migrating volume with rep_status 'not-capable'
When retype migrating a volume with rep_status 'not-capable', cinder driver will reject it because the volumes with rep_status 'not-capable' are considered as a replicated volume. This patch fixes the issue by adding 'not-capable' to the rep_status checklist. Change-Id: I86179c47343de32527d17d7e2177046e89cbd007 Closed-Bug: #1734011
This commit is contained in:
parent
5d0816b0d8
commit
3ac29f6d93
|
@ -917,3 +917,22 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
|
|||
# The volume is successfully removed during the volume delete
|
||||
# and won't exist in the database any more.
|
||||
self.assertRaises(exception.VolumeNotFound, volume.refresh)
|
||||
|
||||
def test_retype_volume_not_capable_to_replica(self):
|
||||
elevated = context.get_admin_context()
|
||||
db.volume_type_create(elevated, {'name': 'old', 'extra_specs': {}})
|
||||
old_vol_type = db.volume_type_get_by_name(elevated, 'old')
|
||||
new_extra_specs = {'replication_enabled': '<is> True'}
|
||||
db.volume_type_create(elevated, {'name': 'new',
|
||||
'extra_specs': new_extra_specs})
|
||||
new_vol_type = db.volume_type_get_by_name(elevated, 'new')
|
||||
volume = tests_utils.create_volume(self.context, size=1,
|
||||
host=CONF.host, status='available',
|
||||
volume_type_id=old_vol_type['id'],
|
||||
replication_status='not-capable')
|
||||
host_obj = {'host': 'newhost', 'capabilities': {}}
|
||||
with mock.patch.object(self.volume,
|
||||
'migrate_volume') as migrate_volume:
|
||||
migrate_volume.return_value = True
|
||||
self.volume.retype(self.context, volume, new_vol_type['id'],
|
||||
host_obj, migration_policy='on-demand')
|
||||
|
|
|
@ -2707,7 +2707,9 @@ class VolumeManager(manager.CleanableManager,
|
|||
|
||||
# Don't allow volume with replicas to be migrated
|
||||
rep_status = volume.replication_status
|
||||
if rep_status is not None and rep_status != 'disabled':
|
||||
if(rep_status is not None and rep_status not in
|
||||
[fields.ReplicationStatus.DISABLED,
|
||||
fields.ReplicationStatus.NOT_CAPABLE]):
|
||||
_retype_error(context, volume, old_reservations,
|
||||
new_reservations, status_update)
|
||||
msg = _("Volume must not be replicated.")
|
||||
|
|
Loading…
Reference in New Issue