Browse Source

Fix bug to run command as root in HDFS driver

A complete proposal is like below steps:
1. Assume the HDFS user in manila.conf has the authority to launch hdfs command.
2. Set run_as_root to False if there is no argument by default, all the cases in
Manila HDFS Driver don't need be a root to run hdfs command.
3. If root is required, please deliver run_as_root parameter and set it as True

Change-Id: I310713c3c1b74ff9990832f61e777cf4c12696fe
Closes-Bug: #1481567
changes/30/211130/1
weiting-chen 6 years ago
parent
commit
bed9b9f3f2
  1. 2
      manila/share/drivers/hdfs/hdfs_native.py
  2. 2
      manila/tests/share/drivers/hdfs/test_hdfs_native.py

2
manila/share/drivers/hdfs/hdfs_native.py

@ -107,7 +107,7 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
def _hdfs_local_execute(self, *cmd, **kwargs):
if 'run_as_root' not in kwargs:
kwargs.update({'run_as_root': True})
kwargs.update({'run_as_root': False})
return utils.execute(*cmd, **kwargs)

2
manila/tests/share/drivers/hdfs/test_hdfs_native.py

@ -358,7 +358,7 @@ class HDFSNativeShareDriverTestCase(test.TestCase):
cmd = 'testcmd'
self.mock_object(utils, 'execute', mock.Mock(return_value=True))
self._driver._hdfs_local_execute(cmd)
utils.execute.assert_called_once_with(cmd, run_as_root=True)
utils.execute.assert_called_once_with(cmd, run_as_root=False)
def test__hdfs_remote_execute(self):
self._driver._run_ssh = mock.Mock(return_value=True)

Loading…
Cancel
Save