Browse Source

Add test case: retype volume when driver not initialized

This patch does two things:
1.In volume-manager, after retyping volume failure, add the volume
status check like in volume-scheduler.
2.Add test case: when retyping available volume, volume driver is
not ready, the volume status will be still 'available'.

Change-Id: I18fa10c978128e744c584e4af28b3f35f655eea6
changes/87/618987/7
caixiaoyu 3 years ago
parent
commit
c3882d9055
  1. 19
      cinder/tests/unit/volume/test_volume_retype.py
  2. 4
      cinder/volume/manager.py

19
cinder/tests/unit/volume/test_volume_retype.py

@ -146,3 +146,22 @@ class VolumeRetypeTestCase(base.BaseVolumeTestCase):
mock_authorize.assert_has_calls(
[mock.call(vol_action_policies.RETYPE_POLICY, target_obj=mock.ANY)
])
def test_retype_driver_not_initialized(self):
volume = tests_utils.create_volume(
self.context,
host=CONF.host,
status='available',
volume_type_id=self.default_vol_type.id)
host_obj = {'host': CONF.host, 'capabilities': {}}
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.retype,
self.context, volume,
self.multiattach_type.id, host_obj,
migration_policy='on-demand')
volume.refresh()
self.assertEqual('available', volume.status)

4
cinder/volume/manager.py

@ -2701,7 +2701,9 @@ class VolumeManager(manager.CleanableManager,
if new_reservations:
QUOTAS.rollback(context, new_reservations)
status_update = {'status': volume.previous_status}
previous_status = (
volume.previous_status or volume.status)
status_update = {'status': previous_status}
if context.project_id != volume.project_id:
project_id = volume.project_id
else:

Loading…
Cancel
Save