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/06/17 22:06:45 UTC

[1/2] mesos git commit: Enabled volume support for mesos-execute.

Repository: mesos
Updated Branches:
  refs/heads/master d2d5c409f -> 81214c872


Enabled volume support for mesos-execute.

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


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

Branch: refs/heads/master
Commit: 81214c872a0d1dcad34003b4f71432a58c0e2875
Parents: 5c7be4b
Author: Guangya Liu <gy...@gmail.com>
Authored: Fri Jun 17 12:00:50 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jun 17 15:06:38 2016 -0700

----------------------------------------------------------------------
 src/cli/execute.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/81214c87/src/cli/execute.cpp
----------------------------------------------------------------------
diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp
index 9b8f8a3..18c2e34 100644
--- a/src/cli/execute.cpp
+++ b/src/cli/execute.cpp
@@ -54,6 +54,8 @@ using std::queue;
 using std::string;
 using std::vector;
 
+using google::protobuf::RepeatedPtrField;
+
 using mesos::internal::devolve;
 
 using mesos::v1::AgentID;
@@ -72,6 +74,7 @@ using mesos::v1::TaskID;
 using mesos::v1::TaskInfo;
 using mesos::v1::TaskState;
 using mesos::v1::TaskStatus;
+using mesos::v1::Volume;
 
 using mesos::v1::scheduler::Call;
 using mesos::v1::scheduler::Event;
@@ -182,6 +185,38 @@ public:
     add(&secret,
         "secret",
         "The secret to use for framework authentication.");
+
+    add(&volumes,
+        "volumes",
+        "The value could be a JSON-formatted string of volumes or a\n"
+        "file path containing the JSON-formatted volumes. Path must\n"
+        "be of the form `file:///path/to/file` or `/path/to/file`.\n"
+        "\n"
+        "See the `Volume` message in `mesos.proto` for the expected format.\n"
+        "\n"
+        "Example:\n"
+        "[\n"
+        "  {\n"
+        "    \"container_path\":\"/path/to/container\"\n"
+        "    \"mode\":\"RW\"\n"
+        "    \"source\":\n"
+        "    {\n"
+        "      \"docker_volume\":\n"
+        "        {\n"
+        "          \"driver\": \"volume_driver\",\n"
+        "          \"docker_options\":\n"
+        "            {\"parameter\":[\n"
+        "              {\n"
+        "                \"key\": \"key\",\n"
+        "                \"value\": \"value\"\n"
+        "              }\n"
+        "            ]},\n"
+        "            \"name\": \"volume_name\"\n"
+        "        },\n"
+        "      \"type\": \"DOCKER_VOLUME\"\n"
+        "    }\n"
+        "  }\n"
+        "]");
   }
 
   Option<string> master;
@@ -197,6 +232,7 @@ public:
   bool checkpoint;
   Option<string> appc_image;
   Option<string> docker_image;
+  Option<JSON::Array> volumes;
   string containerizer;
   string role;
   Option<Duration> kill_after;
@@ -220,6 +256,7 @@ public:
       const Option<string>& _uri,
       const Option<string>& _appcImage,
       const Option<string>& _dockerImage,
+      const vector<Volume>& _volumes,
       const string& _containerizer,
       const Option<Duration>& _killAfter,
       const Option<string>& _networks,
@@ -235,6 +272,7 @@ public:
       uri(_uri),
       appcImage(_appcImage),
       dockerImage(_dockerImage),
+      volumes(_volumes),
       containerizer(_containerizer),
       killAfter(_killAfter),
       networks(_networks),
@@ -528,10 +566,15 @@ private:
 
     ContainerInfo containerInfo;
 
+    foreach (const Volume& volume, volumes) {
+      containerInfo.add_volumes()->CopyFrom(volume);
+    }
+
     // Mesos containerizer supports 'appc' and 'docker' images.
     if (containerizer == "mesos") {
       if (dockerImage.isNone() && appcImage.isNone() &&
-          (networks.isNone() || networks->empty())) {
+          (networks.isNone() || networks->empty()) &&
+          volumes.empty()) {
         return None();
       }
 
@@ -612,6 +655,7 @@ private:
   const Option<string> uri;
   const Option<string> appcImage;
   const Option<string> dockerImage;
+  const vector<Volume> volumes;
   const string containerizer;
   const Option<Duration> killAfter;
   const Option<string> networks;
@@ -756,6 +800,22 @@ int main(int argc, char** argv)
     return EXIT_FAILURE;
   }
 
+  vector<Volume> volumes;
+  if (flags.volumes.isSome()) {
+    Try<RepeatedPtrField<Volume>> _volumes =
+      ::protobuf::parse<RepeatedPtrField<Volume>>(flags.volumes.get());
+
+    if (_volumes.isError()) {
+      cerr << "Failed to convert '--volumes' to protobuf: "
+           << _volumes.error() << endl;
+      return EXIT_FAILURE;
+    }
+
+    foreach (const Volume& volume, _volumes.get()) {
+      volumes.push_back(volume);
+    }
+  }
+
   FrameworkInfo frameworkInfo;
   frameworkInfo.set_user(user.get());
   frameworkInfo.set_name("mesos-execute instance");
@@ -789,6 +849,7 @@ int main(int argc, char** argv)
         uri,
         appcImage,
         dockerImage,
+        volumes,
         flags.containerizer,
         flags.kill_after,
         flags.networks,


[2/2] mesos git commit: Stout: Added parse() for JSON::Array.

Posted by ji...@apache.org.
Stout: Added parse() for JSON::Array.

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


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

Branch: refs/heads/master
Commit: 5c7be4baf4f79e499f83f630de54155f0a2d3af2
Parents: d2d5c40
Author: Guangya Liu <gy...@gmail.com>
Authored: Fri Jun 17 12:00:47 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jun 17 15:06:38 2016 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/flags/parse.hpp | 26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5c7be4ba/3rdparty/stout/include/stout/flags/parse.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/flags/parse.hpp b/3rdparty/stout/include/stout/flags/parse.hpp
index ef365e4..67a89c9 100644
--- a/3rdparty/stout/include/stout/flags/parse.hpp
+++ b/3rdparty/stout/include/stout/flags/parse.hpp
@@ -103,6 +103,32 @@ inline Try<JSON::Object> parse(const std::string& value)
 
 
 template <>
+inline Try<JSON::Array> parse(const std::string& value)
+{
+  // A value that already starts with 'file://' will properly be
+  // loaded from the file and put into 'value' but if it starts with
+  // '/' we need to explicitly handle it for backwards compatibility
+  // reasons (because we used to handle it before we introduced the
+  // 'fetch' mechanism for flags that first fetches the data from URIs
+  // such as 'file://').
+  if (strings::startsWith(value, "/")) {
+    LOG(WARNING) << "Specifying an absolute filename to read a command line "
+                    "option out of without using 'file:// is deprecated and "
+                    "will be removed in a future release. Simply adding "
+                    "'file://' to the beginning of the path should eliminate "
+                    "this warning.";
+
+    Try<std::string> read = os::read(value);
+    if (read.isError()) {
+      return Error("Error reading file '" + value + "': " + read.error());
+    }
+    return JSON::parse<JSON::Array>(read.get());
+  }
+  return JSON::parse<JSON::Array>(value);
+}
+
+
+template <>
 inline Try<Path> parse(const std::string& value)
 {
   return Path(value);