You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by jc...@apache.org on 2016/06/09 17:26:02 UTC
aurora git commit: Don't require user when initializing a Docker
sandbox.
Repository: aurora
Updated Branches:
refs/heads/master e89521f1e -> d26a32358
Don't require user when initializing a Docker sandbox.
Bugs closed: AURORA-1709
Reviewed at https://reviews.apache.org/r/48492/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/d26a3235
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/d26a3235
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/d26a3235
Branch: refs/heads/master
Commit: d26a32358a9f9d16e1d0749afdc9c00b75e52e3b
Parents: e89521f
Author: Joshua Cohen <jc...@apache.org>
Authored: Thu Jun 9 12:25:42 2016 -0500
Committer: Joshua Cohen <jc...@apache.org>
Committed: Thu Jun 9 12:25:42 2016 -0500
----------------------------------------------------------------------
.../apache/aurora/executor/common/sandbox.py | 4 ++-
.../aurora/executor/common/test_sandbox.py | 31 +++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/d26a3235/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 be1deba..6d8b7f5 100644
--- a/src/main/python/apache/aurora/executor/common/sandbox.py
+++ b/src/main/python/apache/aurora/executor/common/sandbox.py
@@ -63,7 +63,9 @@ class DefaultSandboxProvider(SandboxProvider):
def from_assigned_task(self, assigned_task):
container = assigned_task.task.container
- if container.docker or container.mesos and container.mesos.image:
+ if container.docker:
+ return FileSystemImageSandbox(self.SANDBOX_NAME)
+ elif container.mesos and container.mesos.image:
return FileSystemImageSandbox(self.SANDBOX_NAME, self._get_sandbox_user(assigned_task))
else:
return DirectorySandbox(
http://git-wip-us.apache.org/repos/asf/aurora/blob/d26a3235/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 e47d9b8..63f46e2 100644
--- a/src/test/python/apache/aurora/executor/common/test_sandbox.py
+++ b/src/test/python/apache/aurora/executor/common/test_sandbox.py
@@ -18,7 +18,13 @@ import mock
import pytest
from twitter.common.contextutil import temporary_dir
-from apache.aurora.executor.common.sandbox import DirectorySandbox, FileSystemImageSandbox
+from apache.aurora.executor.common.sandbox import (
+ DefaultSandboxProvider,
+ DirectorySandbox,
+ FileSystemImageSandbox
+)
+
+from gen.apache.aurora.api.ttypes import AssignedTask, Container, DockerContainer, TaskConfig
def test_directory_sandbox():
@@ -57,6 +63,29 @@ def test_create(chmod, chown, getpwnam, getgrgid):
chmod.assert_called_with(real_path, 0700)
+@mock.patch('grp.getgrgid')
+@mock.patch('pwd.getpwnam')
+@mock.patch('os.chown')
+@mock.patch('os.chmod')
+def test_create_no_user(*args):
+ with temporary_dir() as d:
+ real_path = os.path.join(d, 'sandbox')
+ ds = DirectorySandbox(real_path)
+ ds.create()
+ assert os.path.exists(real_path)
+
+ for mocked in args:
+ mocked.assert_not_called()
+
+
+@mock.patch.dict(os.environ, {'MESOS_DIRECTORY': '/some/path'})
+def test_sandbox_provider_docker_container():
+ sandbox = DefaultSandboxProvider().from_assigned_task(
+ AssignedTask(task=TaskConfig(container=Container(docker=DockerContainer()))))
+
+ assert sandbox._user is None
+
+
@mock.patch('pwd.getpwnam')
def test_user_does_not_exist(getpwnam):
getpwnam.side_effect = KeyError('johndoe')