Commit 7fec61bd authored by Yuan Gao's avatar Yuan Gao
Browse files

Check if mountpoint is already mounted beforehand for tls mount

parent 3793a746
......@@ -15,10 +15,14 @@ The `efs-utils` package has been verified against the following Linux distributi
| RHEL 8 | `rpm`| `systemd` |
| Fedora 28 | `rpm` | `systemd` |
| Fedora 29 | `rpm` | `systemd` |
| Fedora 30 | `rpm` | `systemd` |
| Fedora 31 | `rpm` | `systemd` |
| Fedora 32 | `rpm` | `systemd` |
| Debian 9 | `deb` | `systemd` |
| Debian 10 | `deb` | `systemd` |
| Ubuntu 16.04 | `deb` | `systemd` |
| Ubuntu 18.04 | `deb` | `systemd` |
| Ubuntu 20.04 | `deb` | `systemd` |
## Prerequisites
......
......@@ -130,6 +130,7 @@ fi
- Fix an issue where subprocess was not killed successfully
- Stop emitting unrecognized init system supervisord if the watchdog daemon has already been launched by supervisor
- Support Fedora
- Check if mountpoint is already mounted beforehand for tls mount
* Tue May 05 2020 Yuan Gao <ygaochn@amazon.com> - 1.25-2
- Fix the issue that IAM role name format is not correctly encoded in python3
......
......@@ -1490,6 +1490,11 @@ def match_device(config, device):
def mount_tls(config, init_system, dns_name, path, fs_id, mountpoint, options):
if os.path.ismount(mountpoint):
sys.stdout.write("%s is already mounted, please run 'mount' command to verify\n" % mountpoint)
logging.warn("%s is already mounted, mount aborted" % mountpoint)
return
with bootstrap_tls(config, init_system, dns_name, fs_id, mountpoint, options) as tunnel_proc:
mount_completed = threading.Event()
t = threading.Thread(target=poll_tunnel_process, args=(tunnel_proc, fs_id, mount_completed))
......
......@@ -11,8 +11,14 @@ import mount_efs
import pytest
from mock import MagicMock
from .. import utils
CONFIG = MagicMock()
DNS_NAME = 'fs-deadbeef.efs.us-east-1.amazonaws.com'
FS_ID = 'fs-deadbeef'
INIT_SYSTEM = 'upstart'
MOUNT_POINT = '/mnt'
PATH = '/'
DEFAULT_OPTIONS = {'nfsvers': 4.1, 'rsize': 1048576, 'wsize': 1048576, 'hard': None, 'timeo': 600, 'retrans': 2, 'tlsport': 3049}
......@@ -93,4 +99,16 @@ def test_mount_nfs_tls_netns(mocker):
assert '/sbin/mount.nfs4' == args[NFS_BIN_ARG_IDX + NETNS_NFS_OFFSET]
assert DNS_NAME not in args[NFS_MOUNT_PATH_IDX + NETNS_NFS_OFFSET]
assert '127.0.0.1' in args[NFS_MOUNT_PATH_IDX + NETNS_NFS_OFFSET]
assert '/mnt' in args[NFS_MOUNT_POINT_IDX + NETNS_NFS_OFFSET]
\ No newline at end of file
assert '/mnt' in args[NFS_MOUNT_POINT_IDX + NETNS_NFS_OFFSET]
def test_mount_tls_mountpoint_mounted(mocker, capsys):
options = dict(DEFAULT_OPTIONS)
options['tls'] = None
bootstrap_tls_mock = mocker.patch('mount_efs.bootstrap_tls')
mocker.patch('os.path.ismount', return_value=True)
mount_efs.mount_tls(CONFIG, INIT_SYSTEM, DNS_NAME, PATH, FS_ID, MOUNT_POINT, options)
out, err = capsys.readouterr()
assert 'is already mounted' in out
utils.assert_not_called(bootstrap_tls_mock)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment