Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 147B2200B54 for ; Thu, 23 Jun 2016 01:01:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1352E160A64; Wed, 22 Jun 2016 23:01:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 47B3F160A6B for ; Thu, 23 Jun 2016 01:01:05 +0200 (CEST) Received: (qmail 19819 invoked by uid 500); 22 Jun 2016 23:01:04 -0000 Mailing-List: contact commits-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mesos.apache.org Delivered-To: mailing list commits@mesos.apache.org Received: (qmail 19573 invoked by uid 99); 22 Jun 2016 23:01:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2016 23:01:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E317BEBFC3; Wed, 22 Jun 2016 23:01:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jieyu@apache.org To: commits@mesos.apache.org Date: Wed, 22 Jun 2016 23:01:07 -0000 Message-Id: <815e83d56b3c4c99affddbe4eb89dc46@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/10] mesos git commit: Added exception for etc hostname mount in cni isolator. archived-at: Wed, 22 Jun 2016 23:01:06 -0000 Added exception for etc hostname mount in cni isolator. Review: https://reviews.apache.org/r/48991/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3805ebb5 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3805ebb5 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3805ebb5 Branch: refs/heads/master Commit: 3805ebb5d0926ba2af1fec2c0644b82c5b71ddc0 Parents: 1498c04 Author: Gilbert Song Authored: Wed Jun 22 16:00:36 2016 -0700 Committer: Jie Yu Committed: Wed Jun 22 16:00:36 2016 -0700 ---------------------------------------------------------------------- .../mesos/isolators/network/cni/cni.cpp | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/3805ebb5/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 8cf5fcb..3e7c107 100644 --- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp +++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp @@ -1498,25 +1498,30 @@ int NetworkCniIsolatorSetup::execute() // rootfs of host filesystem and will later pivot to the rootfs of // the container filesystem, when launching the task. if (!os::exists(file)) { - // 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; - } + // 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); - 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; + if (mount.isError()) { + cerr << "Failed to bind mount from '" << source << "' to '" + << file << "': " << mount.error() << endl; + return EXIT_FAILURE; + } } // Do the bind mount in the container filesystem.