glusterfs_native: Fix Gluster command call
In the delete_snapshot API, the Gluster command issued to delete the snapshot ends up being run in the interactive mode of the Gluster-CLI. So instead of an XML output, the command results in a Gluster-CLI read error. Fix this by forcing the Gluster command to be run in the script mode. Change-Id: Ic09f59732bf08942a9d216f70f1fc969d9ae0a2d Closes-Bug: #1442339
This commit is contained in:
parent
7e75c380a6
commit
6aac2b5693
|
@ -345,7 +345,12 @@ class GlusterfsNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
@staticmethod
|
||||
def _restart_gluster_vol(gluster_mgr):
|
||||
try:
|
||||
# TODO(csaba): eradicate '--mode=script' as it's unnecessary.
|
||||
# TODO(csaba): '--mode=script' ensures that the Gluster CLI runs in
|
||||
# script mode. This seems unnecessary as the Gluster CLI is
|
||||
# expected to run in non-interactive mode when the stdin is not
|
||||
# a terminal, as is the case below. But on testing, found the
|
||||
# behaviour of Gluster-CLI to be the contrary. Need to investigate
|
||||
# this odd-behaviour of Gluster-CLI.
|
||||
gluster_mgr.gluster_call(
|
||||
'volume', 'stop', gluster_mgr.volume, '--mode=script')
|
||||
except exception.ProcessExecutionError as exc:
|
||||
|
@ -669,7 +674,7 @@ class GlusterfsNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
|||
vol = self.db.share_get(context,
|
||||
snapshot['share_id'])['export_location']
|
||||
gluster_mgr = self.gluster_used_vols_dict[vol]
|
||||
args = ('--xml', 'snapshot', 'delete', snapshot['id'])
|
||||
args = ('--xml', 'snapshot', 'delete', snapshot['id'], '--mode=script')
|
||||
try:
|
||||
out, err = gluster_mgr.gluster_call(*args)
|
||||
except exception.ProcessExecutionError as exc:
|
||||
|
|
|
@ -863,7 +863,8 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
|
|||
self._driver.gluster_used_vols_dict = {self.glusterfs_target1: gmgr1}
|
||||
snapshot = {'id': 'fake_snap_id', 'share_id': self.share1['id']}
|
||||
|
||||
args = ('--xml', 'snapshot', 'delete', 'fake_snap_id')
|
||||
args = ('--xml', 'snapshot', 'delete', 'fake_snap_id',
|
||||
'--mode=script')
|
||||
self.mock_object(gmgr1, 'gluster_call',
|
||||
mock.Mock(side_effect=GlusterXMLOut(ret=0, errno=0)))
|
||||
ret = self._driver.delete_snapshot(self._context, snapshot)
|
||||
|
@ -880,7 +881,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
|
|||
self._driver.gluster_used_vols_dict = {self.glusterfs_target1: gmgr1}
|
||||
snapshot = {'id': 'fake_snap_id', 'share_id': self.share1['id']}
|
||||
|
||||
args = ('--xml', 'snapshot', 'delete', 'fake_snap_id')
|
||||
args = ('--xml', 'snapshot', 'delete', 'fake_snap_id', '--mode=script')
|
||||
self.mock_object(gmgr1, 'gluster_call',
|
||||
mock.Mock(side_effect=GlusterXMLOut(ret=-1, errno=2)))
|
||||
self.assertRaises(exception.GlusterfsException,
|
||||
|
|
Loading…
Reference in New Issue