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/07/18 17:24:35 UTC
[3/5] mesos git commit: Ignored /etc/* mounts to host filesystems if
host network is used.
Ignored /etc/* mounts to host filesystems if host network is used.
Review: https://reviews.apache.org/r/50102
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4cef44c2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4cef44c2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4cef44c2
Branch: refs/heads/1.0.x
Commit: 4cef44c2260c498635d96c40aa282a9968877bca
Parents: 3f04d37
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Jul 15 18:37:04 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Jul 18 10:23:39 2016 -0700
----------------------------------------------------------------------
.../mesos/isolators/network/cni/cni.cpp | 54 +++++++++++---------
1 file changed, 30 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4cef44c2/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index 11b826e..5360781 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1515,30 +1515,36 @@ int NetworkCniIsolatorSetup::execute()
// command executor since command executor will be launched with
// rootfs of host filesystem and will later pivot to the rootfs of
// the container filesystem, when launching the task.
- if (!os::exists(file)) {
- // Make an exception for `/etc/hostname`, because it may not
- // exist on every system but hostname is still accessible by
- // `getHostname()`.
- if (file != "/etc/hostname") {
- // NOTE: We just fail if the mount point does not exist on the
- // host filesystem because we don't want to pollute the host
- // filesystem.
- cerr << "Mount point '" << file << "' does not exist "
- << "on the host filesystem" << endl;
- return EXIT_FAILURE;
- }
- } else {
- mount = fs::mount(
- source,
- file,
- None(),
- MS_BIND,
- nullptr);
-
- if (mount.isError()) {
- cerr << "Failed to bind mount from '" << source << "' to '"
- << file << "': " << mount.error() << endl;
- return EXIT_FAILURE;
+ //
+ // NOTE: We only need to do this if non host network is used.
+ // Currently, we use `flags.hostname1 to distinguish if a host
+ // network is being used or not.
+ if (flags.hostname.isSome()) {
+ if (!os::exists(file)) {
+ // Make an exception for `/etc/hostname`, because it may not
+ // exist on every system but hostname is still accessible by
+ // `getHostname()`.
+ if (file != "/etc/hostname") {
+ // NOTE: We just fail if the mount point does not exist on
+ // the host filesystem because we don't want to pollute the
+ // host filesystem.
+ cerr << "Mount point '" << file << "' does not exist "
+ << "on the host filesystem" << endl;
+ return EXIT_FAILURE;
+ }
+ } else {
+ mount = fs::mount(
+ source,
+ file,
+ None(),
+ MS_BIND,
+ nullptr);
+
+ if (mount.isError()) {
+ cerr << "Failed to bind mount from '" << source << "' to '"
+ << file << "': " << mount.error() << endl;
+ return EXIT_FAILURE;
+ }
}
}