Browse Source

[Glusterfs] Fix create share from snapshot failed

1、After performing a snapshot clone of the glusterfs vol,
  the status of the vol is'Created', and the parameter
  "gluster volume set nfs.rpc-auth-reject'*'" is required for
  the vol in the'Started' state.
2、The cloned volume needs to activate the snapshot,
  if the snapshot is already activated, you need to skip the activation step

Closes-Bug: #1922075
Change-Id: I304bf59b3f8c0d5b847078a5752bac8ac4f21690
(cherry picked from commit 63e255248b)
(cherry picked from commit 3635ade670)
changes/67/792167/1
LinPeiWen 7 months ago
committed by Goutham Pacha Ravi
parent
commit
a04e13196c
  1. 33
      manila/share/drivers/glusterfs/layout_volume.py
  2. 13
      manila/tests/share/drivers/glusterfs/test_layout_volume.py
  3. 6
      releasenotes/notes/bug-1922075-fix-Glusterfs-create-share-from-snapshot-failed-053a583522a6fc0e.yaml

33
manila/share/drivers/glusterfs/layout_volume.py

@ -491,9 +491,32 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
backend_snapshot_name = self._find_actual_backend_snapshot_name(
old_gmgr, snapshot)
volume = ''.join(['manila-', share['id']])
args_tuple = (('snapshot', 'activate', backend_snapshot_name,
'force', '--mode=script'),
('snapshot', 'clone', volume, backend_snapshot_name))
# Query the status of the snapshot, if it is Started, the activate
# step will be skipped
args = ('snapshot', 'info', backend_snapshot_name)
out, err = old_gmgr.gluster_call(
*args,
log=("Query the status of the snapshot"))
gfs_snapshot_state = ""
for gfs_snapshot_info in out.split('\t'):
gfs_snapshot_states = re.search(r'Started', gfs_snapshot_info,
re.I)
if gfs_snapshot_states:
gfs_snapshot_state = "Started"
if gfs_snapshot_state == "Started":
args_tuple = (('snapshot', 'clone',
volume, backend_snapshot_name),
('volume', 'start', volume))
else:
args_tuple = (('snapshot', 'activate', backend_snapshot_name,
'force', '--mode=script'),
('snapshot', 'clone', volume,
backend_snapshot_name),
('volume', 'start', volume))
for args in args_tuple:
out, err = old_gmgr.gluster_call(
*args,
@ -507,10 +530,10 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
{'share': share, 'manager': gmgr},
{'share': snapshot['share_instance'], 'manager': old_gmgr})
export = [export, ]
argseq = (('set',
[USER_CLONED_FROM, snapshot['share_id']]),
('set', [USER_MANILA_SHARE, share['id']]),
('start', []))
('set', [USER_MANILA_SHARE, share['id']]))
for op, opargs in argseq:
args = ['volume', op, gmgr.volume] + opargs
gmgr.gluster_call(*args, log=("Creating share from snapshot"))

13
manila/tests/share/drivers/glusterfs/test_layout_volume.py

@ -818,9 +818,10 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
self._layout.gluster_used_vols = set([glusterfs_target])
self._layout.glusterfs_versions = {glusterfs_server: ('3', '7')}
self.mock_object(old_gmgr, 'gluster_call',
mock.Mock(side_effect=[('', ''), ('', '')]))
mock.Mock(side_effect=[
('', ''), ('', ''), ('', ''), ('', '')]))
self.mock_object(new_gmgr, 'gluster_call',
mock.Mock(side_effect=[('', ''), ('', ''), ('', '')]))
mock.Mock(side_effect=[('', ''), ('', '')]))
self.mock_object(new_gmgr, 'get_vol_option',
mock.Mock())
new_gmgr.get_vol_option.return_value = (
@ -841,11 +842,11 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
assert_called_once_with(old_gmgr, snapshot))
args = (('snapshot', 'activate', 'fake_snap_id_xyz',
'force', '--mode=script'),
('snapshot', 'clone', volume, 'fake_snap_id_xyz'))
('snapshot', 'clone', volume, 'fake_snap_id_xyz'),
('volume', 'start', volume))
old_gmgr.gluster_call.assert_has_calls(
[mock.call(*a, log=mock.ANY) for a in args])
args = (('volume', 'start', volume),
('volume', 'set', volume, 'user.manila-share', share['id']),
args = (('volume', 'set', volume, 'user.manila-share', share['id']),
('volume', 'set', volume, 'user.manila-cloned-from',
snapshot['share_id']))
new_gmgr.gluster_call.assert_has_calls(
@ -862,7 +863,7 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
self.assertIn(
new_vol_addr,
self._layout.gluster_used_vols)
self.assertEqual('host1:/gv1', ret)
self.assertEqual(['host1:/gv1'], ret)
def test_create_share_from_snapshot_error_unsupported_gluster_version(
self):

6
releasenotes/notes/bug-1922075-fix-Glusterfs-create-share-from-snapshot-failed-053a583522a6fc0e.yaml

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed `bug #1922075 <https://bugs.launchpad.net/manila/+bug/1922075>`_
Fixed the problem that "gluster volume set nfs.rpc-auth-reject '*'"
failed when the glusterfs driver created an instance from a snapshot.
Loading…
Cancel
Save