aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jco...@apache.org
Subject aurora git commit: Adding logic to copy network files when using the Mesos containierizer with a Docker image.
Date Wed, 19 Oct 2016 21:47:47 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 485504a20 -> f4259c4b7


Adding logic to copy network files when using the Mesos containierizer with a Docker image.

The networking files /etc/resolv.conf, /etc/hosts and /etc/hostname are now copied into the
taskfs
when using the Mesos containierizer with a Docker image.

Bugs closed: AURORA-1798

Reviewed at https://reviews.apache.org/r/53003/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/f4259c4b
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/f4259c4b
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/f4259c4b

Branch: refs/heads/master
Commit: f4259c4b7fd0c8ef8b167a84983281aae43410a9
Parents: 485504a
Author: Justin Pinkul <jpinkul@live.com>
Authored: Wed Oct 19 14:13:28 2016 -0500
Committer: Joshua Cohen <jcohen@apache.org>
Committed: Wed Oct 19 14:13:28 2016 -0500

----------------------------------------------------------------------
 .../apache/aurora/executor/common/sandbox.py    | 15 ++++++++++++++
 .../aurora/executor/common/test_sandbox.py      | 21 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/f4259c4b/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 4a0f3b5..9d6e73c 100644
--- a/src/main/python/apache/aurora/executor/common/sandbox.py
+++ b/src/main/python/apache/aurora/executor/common/sandbox.py
@@ -16,6 +16,7 @@ import getpass
 import grp
 import os
 import pwd
+import shutil
 import subprocess
 from abc import abstractmethod, abstractproperty
 
@@ -298,6 +299,19 @@ class FileSystemImageSandbox(DirectorySandbox):
 
     do_mount(self.root, os.path.join(self._task_fs_root, self._sandbox_mount_point.lstrip('/')))
 
+  def _copy_files(self):
+    def copy_if_exists(source, destination):
+      if os.path.exists(source):
+        shutil.copy(source, destination)
+        log.info('Copying %s into task filesystem at %s.' % (source, destination))
+
+    # TODO(jpinkul): In Mesos the network/cni isolator is responsible for copying these network
+    # files but this logic is being bypassed at the moment due to shelling out to
+    # mesos-containerizer. Once this is no longer necessary this copy should be removed.
+    copy_if_exists('/etc/resolv.conf', os.path.join(self._task_fs_root, 'etc/resolv.conf'))
+    copy_if_exists('/etc/hosts', os.path.join(self._task_fs_root, 'etc/hosts'))
+    copy_if_exists('/etc/hostname', os.path.join(self._task_fs_root, 'etc/hostname'))
+
   @property
   def container_root(self):
     return self._sandbox_mount_point
@@ -313,3 +327,4 @@ class FileSystemImageSandbox(DirectorySandbox):
     super(FileSystemImageSandbox, self).create()
 
     self._mount_paths()
+    self._copy_files()

http://git-wip-us.apache.org/repos/asf/aurora/blob/f4259c4b/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 41ee884..a441d2a 100644
--- a/src/test/python/apache/aurora/executor/common/test_sandbox.py
+++ b/src/test/python/apache/aurora/executor/common/test_sandbox.py
@@ -178,6 +178,27 @@ def test_verify_group_match(mock_check_output):
       sandbox._verify_group_match_in_taskfs(2, 'test-group')
 
 
+def test_verify_network_files():
+  with temporary_dir() as d:
+    task_fs_path = os.path.join(d, 'taskfs')
+    os.makedirs(os.path.join(task_fs_path, 'etc'))
+
+    with mock.patch.dict(os.environ, {'MESOS_DIRECTORY': d}):
+      sandbox = FileSystemImageSandbox(
+          os.path.join(d, 'sandbox'),
+          sandbox_mount_point='/some/sandbox/path')
+
+      sandbox._copy_files()
+
+    def verify_copy(path):
+      if os.path.exists(path):
+        assert os.path.exists(os.path.join(task_fs_path, path.lstrip('/')))
+
+    verify_copy('/etc/resolv.conf')
+    verify_copy('/etc/hostname')
+    verify_copy('/etc/hosts')
+
+
 @mock.patch('subprocess.check_output')
 @mock.patch.dict(os.environ, {'MESOS_DIRECTORY': MOCK_MESOS_DIRECTORY})
 def test_verify_user_match(mock_check_output):


Mime
View raw message