Repository: aurora Updated Branches: refs/heads/master 874625e8f -> c34f78a6d
Clean up leaking of mounts into the host's mtab. Reviewed at https://reviews.apache.org/r/51502/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/c34f78a6 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/c34f78a6 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/c34f78a6 Branch: refs/heads/master Commit: c34f78a6d4cb5b8935c82fe924f58ab480c29535 Parents: 874625e Author: Joshua Cohen <jco...@apache.org> Authored: Mon Aug 29 15:52:44 2016 -0500 Committer: Joshua Cohen <jco...@apache.org> Committed: Mon Aug 29 15:52:44 2016 -0500 ---------------------------------------------------------------------- .../python/apache/aurora/executor/common/sandbox.py | 12 ++++++++---- .../apache/aurora/executor/common/test_sandbox.py | 12 ++++++++---- src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh | 6 ++++++ 3 files changed, 22 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/c34f78a6/src/main/python/apache/aurora/executor/common/sandbox.py ---------------------------------------------------------------------- diff --git a/src/main/python/apache/aurora/executor/common/sandbox.py b/src/main/python/apache/aurora/executor/common/sandbox.py index cedcab6..a172691 100644 --- a/src/main/python/apache/aurora/executor/common/sandbox.py +++ b/src/main/python/apache/aurora/executor/common/sandbox.py @@ -243,11 +243,15 @@ class FileSystemImageSandbox(DirectorySandbox): def do_mount(source, destination): safe_mkdir(destination) log.info('Mounting %s into task filesystem at %s.' % (source, destination)) + + # This mount call is meant to mimic what mesos does when mounting into the container. C.f. + # https://github.com/apache/mesos/blob/c3228f3c3d1a1b2c145d1377185cfe22da6079eb/src/slave/containerizer/mesos/isolators/filesystem/linux.cpp#L521-L528 subprocess.check_call([ - 'mount', - '--bind', - source, - destination]) + 'mount', + '-n', + '--rbind', + source, + destination]) if self._mounted_volume_paths is not None: for container_path in self._mounted_volume_paths: http://git-wip-us.apache.org/repos/asf/aurora/blob/c34f78a6/src/test/python/apache/aurora/executor/common/test_sandbox.py ---------------------------------------------------------------------- diff --git a/src/test/python/apache/aurora/executor/common/test_sandbox.py b/src/test/python/apache/aurora/executor/common/test_sandbox.py index 2ba3341..57ab39e 100644 --- a/src/test/python/apache/aurora/executor/common/test_sandbox.py +++ b/src/test/python/apache/aurora/executor/common/test_sandbox.py @@ -217,19 +217,22 @@ def test_filesystem_sandbox_mounts_paths(mock_safe_mkdir, mock_check_call): assert mock_check_call.mock_calls == [ mock.call([ 'mount', - '--bind', + '-n', + '--rbind', '/some/container/path', os.path.join(task_fs_path, 'some/container/path') ]), mock.call([ 'mount', - '--bind', + '-n', + '--rbind', '/some/other/container/path', os.path.join(task_fs_path, 'some/other/container/path') ]), mock.call([ 'mount', - '--bind', + '-n', + '--rbind', sandbox_directory, os.path.join(task_fs_path, sandbox_mount_point[1:]) ]) @@ -257,7 +260,8 @@ def test_filesystem_sandbox_no_volumes(mock_safe_mkdir, mock_check_call): assert mock_check_call.mock_calls == [ mock.call([ 'mount', - '--bind', + '-n', + '--rbind', sandbox_directory, os.path.join(task_fs_path, sandbox_mount_point[1:]) ]) http://git-wip-us.apache.org/repos/asf/aurora/blob/c34f78a6/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh ---------------------------------------------------------------------- diff --git a/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh b/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh index 7c32c94..d81abe1 100755 --- a/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh +++ b/src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh @@ -428,8 +428,14 @@ test_appc() { popd rm -rf "$TEMP_PATH" + num_mounts_before=$(mount |wc -l |tr -d '\n') + TEST_JOB_APPC_ARGS=("${BASE_ARGS[@]}" "$TEST_JOB_APPC" "--bind appc_image_id=$APPC_IMAGE_ID") test_http_example "${TEST_JOB_APPC_ARGS[@]}" + + num_mounts_after=$(mount |wc -l |tr -d '\n') + # We want to be sure that running the isolated task did not leak any mounts. + [[ "$num_mounts_before" = "$num_mounts_after" ]] } RETCODE=1