Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Neil Hanlon
Efs Utils
Commits
7fec61bd
Commit
7fec61bd
authored
Jun 01, 2020
by
Yuan Gao
Browse files
Check if mountpoint is already mounted beforehand for tls mount
parent
3793a746
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
7fec61bd
...
...
@@ -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
...
...
dist/amazon-efs-utils.spec
View file @
7fec61bd
...
...
@@ -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
...
...
src/mount_efs/__init__.py
View file @
7fec61bd
...
...
@@ -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
))
...
...
test/mount_efs_test/test_mount_nfs.py
View file @
7fec61bd
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment