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
87af3b6d
Commit
87af3b6d
authored
Jul 10, 2018
by
Ian Patel
Browse files
Fix watchdog crashing on stunnel cleanup edge case
parent
7c1e2b3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/watchdog/__init__.py
View file @
87af3b6d
...
...
@@ -78,13 +78,24 @@ def bootstrap_logging(config, log_dir=LOG_DIR):
logging
.
error
(
'Malformed logging level "%s", setting logging level to %s'
,
raw_level
,
level
)
def
parse_options
(
options
):
opts
=
{}
for
o
in
options
.
split
(
','
):
if
'='
in
o
:
k
,
v
=
o
.
split
(
'='
)
opts
[
k
]
=
v
else
:
opts
[
o
]
=
None
return
opts
def
get_file_safe_mountpoint
(
mount
):
mountpoint
=
os
.
path
.
abspath
(
mount
.
mountpoint
).
replace
(
os
.
sep
,
'.'
)
if
mountpoint
.
startswith
(
'.'
):
mountpoint
=
mountpoint
[
1
:]
port
=
mount
.
options
[
mount
.
options
.
find
(
'port'
):].
split
(
','
)[
0
].
split
(
'='
)[
1
]
return
mountpoint
+
'.'
+
port
opts
=
parse_
options
(
mount
.
options
)
return
mountpoint
+
'.'
+
opts
[
'
port
'
]
def
get_current_local_nfs_mounts
(
mount_file
=
'/proc/mounts'
):
...
...
test/watchdog_test/test_get_current_local_nfs_mounts.py
View file @
87af3b6d
...
...
@@ -9,7 +9,8 @@
import
watchdog
MOUNT_FMT_LINE
=
'{address}:/ {mountpoint} {fs_type} rw,port=12345 0 0'
MOUNT_FMT_LINE
=
'{address}:/ {mountpoint} {fs_type} {options} 0 0'
DEFAULT_OPTS
=
'rw,port=12345'
def
_create_mount_file
(
tmpdir
,
lines
):
...
...
@@ -27,7 +28,8 @@ def test_no_mounts(tmpdir):
def
test_no_local_mounts
(
tmpdir
):
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'10.1.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'nfs4'
)])
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'10.1.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'nfs4'
,
options
=
DEFAULT_OPTS
)])
mounts
=
watchdog
.
get_current_local_nfs_mounts
(
mount_file
)
...
...
@@ -35,7 +37,8 @@ def test_no_local_mounts(tmpdir):
def
test_no_local_nfs_mounts
(
tmpdir
):
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'127.0.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'ext4'
)])
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'127.0.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'ext4'
,
options
=
DEFAULT_OPTS
)])
mounts
=
watchdog
.
get_current_local_nfs_mounts
(
mount_file
)
...
...
@@ -43,7 +46,18 @@ def test_no_local_nfs_mounts(tmpdir):
def
test_local_nfs_mount
(
tmpdir
):
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'127.0.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'nfs4'
)])
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'127.0.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'nfs4'
,
options
=
DEFAULT_OPTS
)])
mounts
=
watchdog
.
get_current_local_nfs_mounts
(
mount_file
)
assert
1
==
len
(
mounts
)
assert
'mnt.12345'
in
mounts
def
test_local_nfs_mount_noresvport
(
tmpdir
):
mount_file
=
_create_mount_file
(
tmpdir
,
[
MOUNT_FMT_LINE
.
format
(
address
=
'127.0.0.1'
,
mountpoint
=
'/mnt'
,
fs_type
=
'nfs4'
,
options
=
'rw,noresvport,port=12345'
)])
mounts
=
watchdog
.
get_current_local_nfs_mounts
(
mount_file
)
...
...
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