[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
)
This commit is contained in:
parent
8de6a20379
commit
3635ade670
|
@ -491,9 +491,32 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
||||||
backend_snapshot_name = self._find_actual_backend_snapshot_name(
|
backend_snapshot_name = self._find_actual_backend_snapshot_name(
|
||||||
old_gmgr, snapshot)
|
old_gmgr, snapshot)
|
||||||
volume = ''.join(['manila-', share['id']])
|
volume = ''.join(['manila-', share['id']])
|
||||||
args_tuple = (('snapshot', 'activate', backend_snapshot_name,
|
|
||||||
'force', '--mode=script'),
|
# Query the status of the snapshot, if it is Started, the activate
|
||||||
('snapshot', 'clone', volume, backend_snapshot_name))
|
# 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:
|
for args in args_tuple:
|
||||||
out, err = old_gmgr.gluster_call(
|
out, err = old_gmgr.gluster_call(
|
||||||
*args,
|
*args,
|
||||||
|
@ -507,10 +530,10 @@ class GlusterfsVolumeMappedLayout(layout.GlusterfsShareLayoutBase):
|
||||||
{'share': share, 'manager': gmgr},
|
{'share': share, 'manager': gmgr},
|
||||||
{'share': snapshot['share_instance'], 'manager': old_gmgr})
|
{'share': snapshot['share_instance'], 'manager': old_gmgr})
|
||||||
|
|
||||||
|
export = [export, ]
|
||||||
argseq = (('set',
|
argseq = (('set',
|
||||||
[USER_CLONED_FROM, snapshot['share_id']]),
|
[USER_CLONED_FROM, snapshot['share_id']]),
|
||||||
('set', [USER_MANILA_SHARE, share['id']]),
|
('set', [USER_MANILA_SHARE, share['id']]))
|
||||||
('start', []))
|
|
||||||
for op, opargs in argseq:
|
for op, opargs in argseq:
|
||||||
args = ['volume', op, gmgr.volume] + opargs
|
args = ['volume', op, gmgr.volume] + opargs
|
||||||
gmgr.gluster_call(*args, log=("Creating share from snapshot"))
|
gmgr.gluster_call(*args, log=("Creating share from snapshot"))
|
||||||
|
|
|
@ -818,9 +818,10 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
|
||||||
self._layout.gluster_used_vols = set([glusterfs_target])
|
self._layout.gluster_used_vols = set([glusterfs_target])
|
||||||
self._layout.glusterfs_versions = {glusterfs_server: ('3', '7')}
|
self._layout.glusterfs_versions = {glusterfs_server: ('3', '7')}
|
||||||
self.mock_object(old_gmgr, 'gluster_call',
|
self.mock_object(old_gmgr, 'gluster_call',
|
||||||
mock.Mock(side_effect=[('', ''), ('', '')]))
|
mock.Mock(side_effect=[
|
||||||
|
('', ''), ('', ''), ('', ''), ('', '')]))
|
||||||
self.mock_object(new_gmgr, 'gluster_call',
|
self.mock_object(new_gmgr, 'gluster_call',
|
||||||
mock.Mock(side_effect=[('', ''), ('', ''), ('', '')]))
|
mock.Mock(side_effect=[('', ''), ('', '')]))
|
||||||
self.mock_object(new_gmgr, 'get_vol_option',
|
self.mock_object(new_gmgr, 'get_vol_option',
|
||||||
mock.Mock())
|
mock.Mock())
|
||||||
new_gmgr.get_vol_option.return_value = (
|
new_gmgr.get_vol_option.return_value = (
|
||||||
|
@ -841,11 +842,11 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
|
||||||
assert_called_once_with(old_gmgr, snapshot))
|
assert_called_once_with(old_gmgr, snapshot))
|
||||||
args = (('snapshot', 'activate', 'fake_snap_id_xyz',
|
args = (('snapshot', 'activate', 'fake_snap_id_xyz',
|
||||||
'force', '--mode=script'),
|
'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(
|
old_gmgr.gluster_call.assert_has_calls(
|
||||||
[mock.call(*a, log=mock.ANY) for a in args])
|
[mock.call(*a, log=mock.ANY) for a in args])
|
||||||
args = (('volume', 'start', volume),
|
args = (('volume', 'set', volume, 'user.manila-share', share['id']),
|
||||||
('volume', 'set', volume, 'user.manila-share', share['id']),
|
|
||||||
('volume', 'set', volume, 'user.manila-cloned-from',
|
('volume', 'set', volume, 'user.manila-cloned-from',
|
||||||
snapshot['share_id']))
|
snapshot['share_id']))
|
||||||
new_gmgr.gluster_call.assert_has_calls(
|
new_gmgr.gluster_call.assert_has_calls(
|
||||||
|
@ -862,7 +863,7 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
new_vol_addr,
|
new_vol_addr,
|
||||||
self._layout.gluster_used_vols)
|
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(
|
def test_create_share_from_snapshot_error_unsupported_gluster_version(
|
||||||
self):
|
self):
|
||||||
|
|
|
@ -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…
Reference in New Issue