diff --git a/cinder/tests/unit/test_nfs.py b/cinder/tests/unit/test_nfs.py index 6af7f772f42..3c8ce6c821f 100644 --- a/cinder/tests/unit/test_nfs.py +++ b/cinder/tests/unit/test_nfs.py @@ -1283,13 +1283,13 @@ class NfsDriverDoSetupTestCase(test.TestCase): errno.ENOENT, 'No such file or directory.') with self.assertRaisesRegex(exception.NfsException, - 'mount.nfs is not installed'): + '/sbin/mount.nfs is not installed'): drv.do_setup(self.context) mock_os_path_exists.assert_has_calls( [mock.call(self.configuration.nfs_shares_config)]) mock_execute.assert_has_calls( - [mock.call('mount.nfs', + [mock.call('/sbin/mount.nfs', check_exit_code=False, run_as_root=False)]) @@ -1313,7 +1313,7 @@ class NfsDriverDoSetupTestCase(test.TestCase): mock_os_path_exists.assert_has_calls( [mock.call(self.configuration.nfs_shares_config)]) mock_execute.assert_has_calls( - [mock.call('mount.nfs', + [mock.call('/sbin/mount.nfs', check_exit_code=False, run_as_root=False)]) diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py index 9aea7337f92..c5ecf34074f 100644 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -143,9 +143,14 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver): self.shares = {} # address : options - # Check if mount.nfs is installed on this system; note that we don't - # need to be root to see if the package is installed. - package = 'mount.nfs' + # Check if /sbin/mount.nfs is installed on this system; + # note that we don't need to be root, to see if the package + # is installed. + # We rely on the absolute path /sbin/mount.nfs; this seems to be + # common on most distributions (SUSE, RedHat, CentOS, Ubuntu, Debian) + # and it does not depend on correct PATH of the executing user, + # when trying to find the relative binary. + package = '/sbin/mount.nfs' try: self._execute(package, check_exit_code=False, run_as_root=False)