Merge "NFS: Update connection info on online snap create" into stable/train
This commit is contained in:
commit
d8d84b7c65
|
@ -289,6 +289,18 @@ class RemoteFsSnapDriverTestCase(test.TestCase):
|
|||
self._fake_snapshot.volume.status = 'backing-up'
|
||||
self._fake_snapshot.volume.attach_status = 'attached'
|
||||
expected_method_called = '_create_snapshot_online'
|
||||
conn_info = ('{"driver_volume_type": "nfs",'
|
||||
'"export": "localhost:/srv/nfs1",'
|
||||
'"name": "old_name"}')
|
||||
attachment = fake_volume.volume_attachment_ovo(
|
||||
self.context, connection_info=conn_info)
|
||||
snapshot.volume.volume_attachment.objects.append(attachment)
|
||||
mock_save = self.mock_object(attachment, 'save')
|
||||
|
||||
# After the snapshot the connection info should change the name of
|
||||
# the file
|
||||
expected = copy.deepcopy(attachment.connection_info)
|
||||
expected['name'] = snapshot.volume.name + '.' + snapshot.id
|
||||
else:
|
||||
expected_method_called = '_do_create_snapshot'
|
||||
|
||||
|
@ -305,6 +317,11 @@ class RemoteFsSnapDriverTestCase(test.TestCase):
|
|||
mock.sentinel.fake_info_path,
|
||||
expected_snapshot_info)
|
||||
|
||||
if volume_in_use:
|
||||
mock_save.assert_called_once()
|
||||
changed_fields = attachment.cinder_obj_get_changes()
|
||||
self.assertEqual(expected, changed_fields['connection_info'])
|
||||
|
||||
def test_create_snapshot_volume_available(self):
|
||||
self._test_create_snapshot()
|
||||
|
||||
|
|
|
@ -1452,18 +1452,25 @@ class RemoteFSSnapDriverBase(RemoteFSDriver):
|
|||
backing_filename = self.get_active_image_from_info(
|
||||
snapshot.volume)
|
||||
new_snap_path = self._get_new_snap_path(snapshot)
|
||||
active = os.path.basename(new_snap_path)
|
||||
|
||||
if self._is_volume_attached(snapshot.volume):
|
||||
self._create_snapshot_online(snapshot,
|
||||
backing_filename,
|
||||
new_snap_path)
|
||||
# Update reference in the only attachment (no multi-attach support)
|
||||
attachment = snapshot.volume.volume_attachment[0]
|
||||
attachment.connection_info['name'] = active
|
||||
# Let OVO know it has been updated
|
||||
attachment.connection_info = attachment.connection_info
|
||||
attachment.save()
|
||||
else:
|
||||
self._do_create_snapshot(snapshot,
|
||||
backing_filename,
|
||||
new_snap_path)
|
||||
|
||||
snap_info['active'] = os.path.basename(new_snap_path)
|
||||
snap_info[snapshot.id] = os.path.basename(new_snap_path)
|
||||
snap_info['active'] = active
|
||||
snap_info[snapshot.id] = active
|
||||
self._write_info_file(info_path, snap_info)
|
||||
|
||||
def _create_snapshot_online(self, snapshot, backing_filename,
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
NFS driver `bug #1860913
|
||||
<https://bugs.launchpad.net/cinder/+bug/1860913>`_: Fixed instance uses
|
||||
base image file when it is rebooted after online snapshot creation.
|
Loading…
Reference in New Issue