RemoteFS: don't fail in do_mount if already mounted
This fixes a problem where two different callers are
mounting a share at the same time:
A: check if share is mounted
B: check if share is mounted
A: mount share
B: mount share (fails because it is already mounted)
Closes-Bug: 1780813
Change-Id: I6eca9c9e9eceb7aef357b0ed77bf157ac0010bfe
(cherry picked from commit 2f32c98a65
)
This commit is contained in:
parent
8fab1a01cb
commit
dc5935df10
|
@ -20,6 +20,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from oslo_concurrency import processutils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@ -116,8 +117,16 @@ class RemoteFsClient(executor.Executor):
|
||||||
mnt_cmd.extend(flags)
|
mnt_cmd.extend(flags)
|
||||||
mnt_cmd.extend([share, mount_path])
|
mnt_cmd.extend([share, mount_path])
|
||||||
|
|
||||||
self._execute(*mnt_cmd, root_helper=self._root_helper,
|
try:
|
||||||
run_as_root=True, check_exit_code=0)
|
self._execute(*mnt_cmd, root_helper=self._root_helper,
|
||||||
|
run_as_root=True, check_exit_code=0)
|
||||||
|
except processutils.ProcessExecutionError as exc:
|
||||||
|
if 'already mounted' in exc.stderr:
|
||||||
|
LOG.info("Already mounted: %s", share)
|
||||||
|
else:
|
||||||
|
LOG.error("Failed to mount %(share)s, reason: %(reason)s",
|
||||||
|
{'share': share, 'reason': exc.stderr})
|
||||||
|
raise
|
||||||
|
|
||||||
def _mount_nfs(self, nfs_share, mount_path, flags=None):
|
def _mount_nfs(self, nfs_share, mount_path, flags=None):
|
||||||
"""Mount nfs share using present mount types."""
|
"""Mount nfs share using present mount types."""
|
||||||
|
|
Loading…
Reference in New Issue