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/04/24 20:47:28 UTC

[2/2] mesos git commit: Enabled Sequence mount for prepare() in docker volume isolator.

Enabled Sequence mount for prepare() in docker volume isolator.

Review: https://reviews.apache.org/r/44454


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

Branch: refs/heads/master
Commit: e92cc460a7caf220bbb61941bb49e24e739f4b4a
Parents: 65c35fd
Author: Guangya Liu <gy...@gmail.com>
Authored: Sun Apr 24 11:46:29 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Sun Apr 24 11:46:29 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/docker/volume/isolator.cpp  | 27 +++++++++++++++++++-
 .../mesos/isolators/docker/volume/isolator.hpp  | 18 +++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e92cc460/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
index eb23ef6..752707c 100644
--- a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
+++ b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.cpp
@@ -367,7 +367,7 @@ Future<Option<ContainerLaunchInfo>> DockerVolumeIsolatorProcess::prepare(
   // Invoke driver client to create the mount.
   list<Future<string>> futures;
   foreach (const Mount& mount, mounts) {
-    futures.push_back(client->mount(
+    futures.push_back(this->mount(
         mount.volume.driver(),
         mount.volume.name(),
         mount.options));
@@ -551,6 +551,31 @@ Future<Nothing> DockerVolumeIsolatorProcess::_cleanup(
   return Nothing();
 }
 
+
+Future<string> DockerVolumeIsolatorProcess::mount(
+    const string& driver,
+    const string& name,
+    const hashmap<string, string>& options)
+{
+  DockerVolume volume;
+  volume.set_driver(driver);
+  volume.set_name(name);
+
+  return sequences[volume].add<string>(
+      defer(PID<DockerVolumeIsolatorProcess>(this), [=]() -> Future<string> {
+        return _mount(driver, name, options);
+      }));
+}
+
+
+Future<string> DockerVolumeIsolatorProcess::_mount(
+    const string& driver,
+    const string& name,
+    const hashmap<string, string>& options)
+{
+  return client->mount(driver, name, options);
+}
+
 } // namespace slave {
 } // namespace internal {
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/e92cc460/src/slave/containerizer/mesos/isolators/docker/volume/isolator.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.hpp b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.hpp
index 5144776..b183bf3 100644
--- a/src/slave/containerizer/mesos/isolators/docker/volume/isolator.hpp
+++ b/src/slave/containerizer/mesos/isolators/docker/volume/isolator.hpp
@@ -22,8 +22,11 @@
 #include <vector>
 
 #include <process/owned.hpp>
+#include <process/sequence.hpp>
 
 #include <stout/hashmap.hpp>
+#include <stout/none.hpp>
+#include <stout/option.hpp>
 
 #include "slave/containerizer/mesos/isolator.hpp"
 
@@ -94,11 +97,26 @@ private:
 
   Try<Nothing> _recover(const ContainerID& containerId);
 
+  process::Future<std::string> mount(
+      const std::string& driver,
+      const std::string& name,
+      const hashmap<std::string, std::string>& options);
+
+  process::Future<std::string> _mount(
+      const std::string& driver,
+      const std::string& name,
+      const hashmap<std::string, std::string>& options);
+
   const Flags flags;
   const std::string rootDir;
   const process::Owned<docker::volume::DriverClient> client;
 
   hashmap<ContainerID, process::Owned<Info>> infos;
+
+  // For a given volume, the docker volume isolator might be doing
+  // mounting and unmounting simultaneously. The sequence can make
+  // sure the order we issue them is the same order they are executed.
+  hashmap<DockerVolume, process::Sequence> sequences;
 };
 
 } // namespace slave {