You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/08/03 00:02:07 UTC
[2/6] mesos git commit: Supported scratch containers in Unified
Containerizer.
Supported scratch containers in Unified Containerizer.
Before this patch, we are assuming the 'tmpfs' mount point '/tmp'
always exist in the container's new rootfs. However, this is not
true. For the scratch container (which is a common case), '/tmp'
may not exist, and there may only be an executable binary in the
new rootfs. So we need to create the mount point for 'tmpfs' in
fs::enter().
However, this change may break some cases using the bind backend,
because we are not able the create the '/tmp' mount point in a
read-only filesystem. So we require users to make sure the
directory '/tmp' must already exist in their single layer scratch
images for the following reasons:
1. For most cases, when operators prefer using the bind backend,
the single-layer images are usually large in size, and '/tmp'
exists in the rootfs.
2. For scratch images, most of them contain more than one layer,
which means the bind backend cannot be used in those cases.
So we can create the '/tmp' mount point if it does not exist.
3. If this is strictly a single layer scratch image, it is
reasonable that we require users to make sure the mount point
'/tmp' existed in the image rootfs if they are using the bind
backend, because we already require the sandbox mount point
to be existed in those iamges.
Review: https://reviews.apache.org/r/50719/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/98ffcb1b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/98ffcb1b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/98ffcb1b
Branch: refs/heads/master
Commit: 98ffcb1b69b4e233beb428bb63fc99d9e09245c2
Parents: 1cd3602
Author: Gilbert Song <so...@gmail.com>
Authored: Tue Aug 2 16:49:43 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 2 16:49:43 2016 -0700
----------------------------------------------------------------------
src/linux/fs.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/98ffcb1b/src/linux/fs.cpp
----------------------------------------------------------------------
diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp
index 27d322c..f57db80 100644
--- a/src/linux/fs.cpp
+++ b/src/linux/fs.cpp
@@ -601,8 +601,15 @@ Try<Nothing> enter(const string& root)
// new root is writable (i.e., it could be a read only filesystem).
// Therefore, we always mount a tmpfs on /tmp in the new root so
// that we can create the mount point for the old root.
- if (!os::exists(path::join(root, "tmp"))) {
- return Error("/tmp in chroot does not exist");
+ //
+ // NOTE: If the new root is a read-only filesystem (e.g., using bind
+ // backend), the 'tmpfs' mount point '/tmp' must already exist in the
+ // new root. Otherwise, mkdir would return an error because of unable
+ // to create it in read-only filesystem.
+ Try<Nothing> mkdir = os::mkdir(path::join(root, "tmp"));
+ if (mkdir.isError()) {
+ return Error("Failed to create 'tmpfs' mount point at '" +
+ path::join(root, "tmp") + "': " + mkdir.error());
}
// TODO(jieyu): Consider limiting the size of the tmpfs.