You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2018/08/14 23:57:53 UTC

[mesos] 01/10: Updated `volume/host_path` isolator to honor volume mode.

This is an automated email from the ASF dual-hosted git repository.

gilbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 374f7720bf2fdb2ab9dc584618c7ae51b2a9b416
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Tue Aug 14 16:19:13 2018 -0700

    Updated `volume/host_path` isolator to honor volume mode.
    
    Review: https://reviews.apache.org/r/68212/
---
 src/slave/containerizer/mesos/isolators/volume/host_path.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/slave/containerizer/mesos/isolators/volume/host_path.cpp b/src/slave/containerizer/mesos/isolators/volume/host_path.cpp
index 9127cf4..2e03ef5 100644
--- a/src/slave/containerizer/mesos/isolators/volume/host_path.cpp
+++ b/src/slave/containerizer/mesos/isolators/volume/host_path.cpp
@@ -309,11 +309,17 @@ Future<Option<ContainerLaunchInfo>> VolumeHostPathIsolatorProcess::prepare(
     // result, no need for the bind mount because the 'hostPath' is
     // already accessible in the container.
     if (hostPath.get() != mountPoint) {
-      // TODO(jieyu): Consider the mode in the volume.
       ContainerMountInfo* mount = launchInfo.add_mounts();
       mount->set_source(hostPath.get());
       mount->set_target(mountPoint);
       mount->set_flags(MS_BIND | MS_REC);
+
+      // If the mount needs to be read-only, do a remount.
+      if (volume.mode() == Volume::RO) {
+        mount = launchInfo.add_mounts();
+        mount->set_target(mountPoint);
+        mount->set_flags(MS_BIND | MS_RDONLY | MS_REMOUNT);
+      }
     }
   }