You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/08/01 12:33:54 UTC

[2/2] mesos git commit: Added `--executor_uris` flag to long lived and balloon frameworks.

Added `--executor_uris` flag to long lived and balloon frameworks.

Allows to set URIs that will be fetched before running the executor.

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


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

Branch: refs/heads/master
Commit: e3741930e87c3898a08460f038e3d58c63a57699
Parents: c65fb00
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Tue Aug 1 12:13:45 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Tue Aug 1 14:31:15 2017 +0200

----------------------------------------------------------------------
 src/examples/balloon_framework.cpp    | 57 ++++++++++++++++++++++++++++--
 src/examples/long_lived_framework.cpp | 57 ++++++++++++++++++++++++++++--
 2 files changed, 110 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e3741930/src/examples/balloon_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_framework.cpp b/src/examples/balloon_framework.cpp
index b8c8e38..dfd049b 100644
--- a/src/examples/balloon_framework.cpp
+++ b/src/examples/balloon_framework.cpp
@@ -40,13 +40,18 @@
 #include <stout/option.hpp>
 #include <stout/os.hpp>
 #include <stout/path.hpp>
+#include <stout/protobuf.hpp>
 #include <stout/stringify.hpp>
 
+#include "common/parse.hpp"
+
 using namespace mesos;
 using namespace mesos::internal;
 
 using std::string;
 
+using google::protobuf::RepeatedPtrField;
+
 using process::Clock;
 using process::defer;
 
@@ -97,7 +102,29 @@ public:
 
     add(&Flags::executor_uri,
         "executor_uri",
-        "URI the fetcher should use to get the executor.");
+        "URI the fetcher should use to get the executor's binary.\n"
+        "NOTE: This flag is deprecated in favor of `--executor_uris`");
+
+    add(&Flags::executor_uris,
+        "executor_uris",
+        "The value could be a JSON-formatted string of `URI`s that\n"
+        "should be fetched before running the executor, or a file\n"
+        "path containing the JSON-formatted `URI`s. Path must be of\n"
+        "the form `file:///path/to/file` or `/path/to/file`.\n"
+        "This flag replaces `--executor_uri`.\n"
+        "See the `CommandInfo::URI` message in `mesos.proto` for the\n"
+        "expected format.\n"
+        "Example:\n"
+        "[\n"
+        "  {\n"
+        "    \"value\":\"mesos.apache.org/balloon_executor\",\n"
+        "    \"executable\":\"true\"\n"
+        "  },\n"
+        "  {\n"
+        "    \"value\":\"mesos.apache.org/bundle_for_executor.tar.gz\",\n"
+        "    \"cache\":\"true\"\n"
+        "  }\n"
+        "]");
 
     add(&Flags::executor_command,
         "executor_command",
@@ -120,9 +147,13 @@ public:
   Bytes task_memory_usage_limit;
   Bytes task_memory;
 
-  // Flags for specifying the executor binary.
+  // Flags for specifying the executor binary and other URIs.
+  //
+  // TODO(armand): Remove the `--executor_uri` flag after the
+  // deprecation cycle, started in 1.4.0.
   Option<string> build_dir;
   Option<string> executor_uri;
+  Option<JSON::Array> executor_uris;
   Option<string> executor_command;
 
   bool checkpoint;
@@ -486,13 +517,35 @@ int main(int argc, char** argv)
 
   executor.mutable_command()->set_value(command);
 
+  if (flags.executor_uris.isSome() && flags.executor_uri.isSome()) {
+    EXIT(EXIT_FAILURE)
+      << "Flag '--executor_uris' shall not be used with '--executor_uri'";
+  }
+
   // Copy `--executor_uri` into the command.
   if (flags.executor_uri.isSome()) {
+    LOG(WARNING)
+      << "Flag '--executor_uri' is deprecated, use '--executor_uris' instead";
+
     mesos::CommandInfo::URI* uri = executor.mutable_command()->add_uris();
     uri->set_value(flags.executor_uri.get());
     uri->set_executable(true);
   }
 
+  // Copy `--executor_uris` into the command.
+  if (flags.executor_uris.isSome()) {
+    Try<RepeatedPtrField<mesos::CommandInfo::URI>> parse =
+      ::protobuf::parse<RepeatedPtrField<mesos::CommandInfo::URI>>(
+          flags.executor_uris.get());
+
+    if (parse.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to convert '--executor_uris' to protobuf: " << parse.error();
+    }
+
+    executor.mutable_command()->mutable_uris()->CopyFrom(parse.get());
+  }
+
   FrameworkInfo framework;
   framework.set_user(os::user().get());
   framework.set_name("Balloon Framework (C++)");

http://git-wip-us.apache.org/repos/asf/mesos/blob/e3741930/src/examples/long_lived_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/long_lived_framework.cpp b/src/examples/long_lived_framework.cpp
index af5b43e..2a79dfd 100644
--- a/src/examples/long_lived_framework.cpp
+++ b/src/examples/long_lived_framework.cpp
@@ -42,12 +42,17 @@
 #include <stout/option.hpp>
 #include <stout/os.hpp>
 #include <stout/path.hpp>
+#include <stout/protobuf.hpp>
 #include <stout/stringify.hpp>
 
+#include "common/parse.hpp"
+
 using std::queue;
 using std::string;
 using std::vector;
 
+using google::protobuf::RepeatedPtrField;
+
 using mesos::v1::AgentID;
 using mesos::v1::CommandInfo;
 using mesos::v1::Credential;
@@ -494,7 +499,29 @@ public:
 
     add(&Flags::executor_uri,
         "executor_uri",
-        "URI the fetcher should use to get the executor.");
+        "URI the fetcher should use to get the executor's binary.\n"
+        "NOTE: This flag is deprecated in favor of `--executor_uris`");
+
+    add(&Flags::executor_uris,
+        "executor_uris",
+        "The value could be a JSON-formatted string of `URI`s that\n"
+        "should be fetched before running the executor, or a file\n"
+        "path containing the JSON-formatted `URI`s. Path must be of\n"
+        "the form `file:///path/to/file` or `/path/to/file`.\n"
+        "This flag replaces `--executor_uri`.\n"
+        "See the `CommandInfo::URI` message in `mesos.proto` for the\n"
+        "expected format.\n"
+        "Example:\n"
+        "[\n"
+        "  {\n"
+        "    \"value\":\"mesos.apache.org/balloon_executor\",\n"
+        "    \"executable\":\"true\"\n"
+        "  },\n"
+        "  {\n"
+        "    \"value\":\"mesos.apache.org/bundle_for_executor.tar.gz\",\n"
+        "    \"cache\":\"true\"\n"
+        "  }\n"
+        "]");
 
     add(&Flags::executor_command,
         "executor_command",
@@ -517,9 +544,13 @@ public:
 
   Option<string> master;
 
-  // Flags for specifying the executor binary.
+  // Flags for specifying the executor binary and other URIs.
+  //
+  // TODO(armand): Remove the `--executor_uri` flag after the
+  // deprecation cycle, started in 1.4.0.
   Option<string> build_dir;
   Option<string> executor_uri;
+  Option<JSON::Array> executor_uris;
   Option<string> executor_command;
 
   bool checkpoint;
@@ -574,13 +605,35 @@ int main(int argc, char** argv)
 
   executor.mutable_command()->set_value(command);
 
+  if (flags.executor_uris.isSome() && flags.executor_uri.isSome()) {
+    EXIT(EXIT_FAILURE)
+      << "Flag '--executor_uris' shall not be used with '--executor_uri'";
+  }
+
   // Copy `--executor_uri` into the command.
   if (flags.executor_uri.isSome()) {
+    LOG(WARNING)
+      << "Flag '--executor_uri' is deprecated, use '--executor_uris' instead";
+
     CommandInfo::URI* uri = executor.mutable_command()->add_uris();
     uri->set_value(flags.executor_uri.get());
     uri->set_executable(true);
   }
 
+  // Copy `--executor_uris` into the command.
+  if (flags.executor_uris.isSome()) {
+    Try<RepeatedPtrField<CommandInfo::URI>> parse =
+      ::protobuf::parse<RepeatedPtrField<CommandInfo::URI>>(
+          flags.executor_uris.get());
+
+    if (parse.isError()) {
+      EXIT(EXIT_FAILURE)
+        << "Failed to convert '--executor_uris' to protobuf: " << parse.error();
+    }
+
+    executor.mutable_command()->mutable_uris()->CopyFrom(parse.get());
+  }
+
   FrameworkInfo framework;
   framework.set_user(os::user().get());
   framework.set_name("Long Lived Framework (C++)");