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 2016/04/12 12:43:00 UTC

[1/3] mesos git commit: Extended logging for task status updates in mesos-execute.

Repository: mesos
Updated Branches:
  refs/heads/master 0426ffbbf -> 371072e97


Extended logging for task status updates in mesos-execute.

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


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

Branch: refs/heads/master
Commit: a6a428a492ace993d3d60d6a925c766a2c8511a5
Parents: 0426ffb
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Tue Apr 12 12:33:55 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Tue Apr 12 12:33:55 2016 +0200

----------------------------------------------------------------------
 src/cli/execute.cpp | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a6a428a4/src/cli/execute.cpp
----------------------------------------------------------------------
diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp
index 763dd26..51fb96a 100644
--- a/src/cli/execute.cpp
+++ b/src/cli/execute.cpp
@@ -341,8 +341,8 @@ protected:
 
         mesos->send(call);
 
-        cout << "task " << name << " submitted to agent "
-             << offer.agent_id() << endl;
+        cout << "Submitted task '" << name << "' to agent '"
+             << offer.agent_id() << "'" << endl;
 
         launched = true;
       } else {
@@ -373,7 +373,7 @@ protected:
 
           state = SUBSCRIBED;
 
-          cout << "Subscribed with ID '" << frameworkInfo.id() << endl;
+          cout << "Subscribed with ID '" << frameworkInfo.id() << "'" << endl;
           break;
         }
 
@@ -414,7 +414,19 @@ protected:
     CHECK_EQ(name, status.task_id().value());
 
     cout << "Received status update " << status.state()
-         << " for task " << status.task_id() << endl;
+         << " for task '" << status.task_id() << "'" << endl;
+    if (status.has_message()) {
+      cout << "  message: '" << status.message() << "'" << endl;
+    }
+    if (status.has_source()) {
+      cout << "  source: " << TaskStatus::Source_Name(status.source()) << endl;
+    }
+    if (status.has_source()) {
+      cout << "  reason: " << TaskStatus::Reason_Name(status.reason()) << endl;
+    }
+    if (status.has_healthy()) {
+      cout << "  healthy?: " << status.healthy() << endl;
+    }
 
     if (status.has_uuid()) {
       Call call;
@@ -655,7 +667,7 @@ int main(int argc, char** argv)
 
   FrameworkInfo frameworkInfo;
   frameworkInfo.set_user(user.get());
-  frameworkInfo.set_name("");
+  frameworkInfo.set_name("mesos-execute instance");
   frameworkInfo.set_role(flags.role);
   frameworkInfo.set_checkpoint(flags.checkpoint);
 


[3/3] mesos git commit: Introduced kill task delay in mesos-execute.

Posted by al...@apache.org.
Introduced kill task delay in mesos-execute.

Adds a flag that specifies a delay after which the task should be
killed. If set, a kill task request is scheduled to be sent after
TASK_RUNNING status update has been received. Also adds support for
TASK_KILLING capability.

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


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

Branch: refs/heads/master
Commit: 371072e973f3e918535917f14d3167becfe8166f
Parents: 81a1d82
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Tue Apr 12 12:34:18 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Tue Apr 12 12:34:18 2016 +0200

----------------------------------------------------------------------
 src/cli/execute.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/371072e9/src/cli/execute.cpp
----------------------------------------------------------------------
diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp
index 88e36b6..306779f 100644
--- a/src/cli/execute.cpp
+++ b/src/cli/execute.cpp
@@ -31,6 +31,7 @@
 #include <process/protobuf.hpp>
 
 #include <stout/check.hpp>
+#include <stout/duration.hpp>
 #include <stout/flags.hpp>
 #include <stout/foreach.hpp>
 #include <stout/hashmap.hpp>
@@ -55,6 +56,7 @@ using std::vector;
 
 using mesos::internal::devolve;
 
+using mesos::v1::AgentID;
 using mesos::v1::CommandInfo;
 using mesos::v1::ContainerInfo;
 using mesos::v1::Environment;
@@ -65,7 +67,9 @@ using mesos::v1::Label;
 using mesos::v1::Labels;
 using mesos::v1::Offer;
 using mesos::v1::Resources;
+using mesos::v1::TaskID;
 using mesos::v1::TaskInfo;
+using mesos::v1::TaskState;
 using mesos::v1::TaskStatus;
 
 using mesos::v1::scheduler::Call;
@@ -159,6 +163,11 @@ public:
         "role",
         "Role to use when registering.",
         "*");
+
+    add(&kill_after,
+        "kill_after",
+        "Specifies a delay after which the task is killed\n"
+        "(e.g., 10secs, 2mins, etc).");
   }
 
   Option<string> master;
@@ -176,6 +185,7 @@ public:
   Option<string> docker_image;
   string containerizer;
   string role;
+  Option<Duration> kill_after;
 };
 
 
@@ -193,7 +203,8 @@ public:
       const Option<string>& _uri,
       const Option<string>& _appcImage,
       const Option<string>& _dockerImage,
-      const string& _containerizer)
+      const string& _containerizer,
+      const Option<Duration>& _killAfter)
     : state(DISCONNECTED),
       frameworkInfo(_frameworkInfo),
       master(_master),
@@ -206,6 +217,7 @@ public:
       appcImage(_appcImage),
       dockerImage(_dockerImage),
       containerizer(_containerizer),
+      killAfter(_killAfter),
       launched(false) {}
 
   virtual ~CommandScheduler() {}
@@ -256,6 +268,24 @@ protected:
     process::delay(Seconds(1), self(), &Self::doReliableRegistration);
   }
 
+  void killTask(const TaskID& taskId, const AgentID& agentId)
+  {
+    cout << "Asked to kill task '" << taskId
+         << "' on agent '" << agentId << "'" << endl;
+
+    Call call;
+    call.set_type(Call::KILL);
+
+    CHECK(frameworkInfo.has_id());
+    call.mutable_framework_id()->CopyFrom(frameworkInfo.id());
+
+    Call::Kill* kill = call.mutable_kill();
+    kill->mutable_task_id()->CopyFrom(taskId);
+    kill->mutable_agent_id()->CopyFrom(agentId);
+
+    mesos->send(call);
+  }
+
   void offers(const vector<Offer>& offers)
   {
     CHECK_EQ(SUBSCRIBED, state);
@@ -444,6 +474,15 @@ protected:
       mesos->send(call);
     }
 
+    // If a task kill delay has been specified, schedule task kill.
+    if (killAfter.isSome() && TaskState::TASK_RUNNING == status.state()) {
+      delay(killAfter.get(),
+            self(),
+            &Self::killTask,
+            status.task_id(),
+            status.agent_id());
+    }
+
     if (mesos::internal::protobuf::isTerminalState(devolve(status).state())) {
       terminate(self());
     }
@@ -531,6 +570,8 @@ private:
   const Option<string> appcImage;
   const Option<string> dockerImage;
   const string containerizer;
+  const Option<Duration> killAfter;
+
   bool launched;
   Owned<Mesos> mesos;
 };
@@ -671,6 +712,8 @@ int main(int argc, char** argv)
   frameworkInfo.set_name("mesos-execute instance");
   frameworkInfo.set_role(flags.role);
   frameworkInfo.set_checkpoint(flags.checkpoint);
+  frameworkInfo.add_capabilities()->set_type(
+      FrameworkInfo::Capability::TASK_KILLING_STATE);
 
   Owned<CommandScheduler> scheduler(
       new CommandScheduler(
@@ -684,7 +727,8 @@ int main(int argc, char** argv)
         uri,
         appcImage,
         dockerImage,
-        flags.containerizer));
+        flags.containerizer,
+        flags.kill_after));
 
   process::spawn(scheduler.get());
   process::wait(scheduler.get());


[2/3] mesos git commit: Cleaned up flag descriptions in mesos-execute.

Posted by al...@apache.org.
Cleaned up flag descriptions in mesos-execute.

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


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

Branch: refs/heads/master
Commit: 81a1d82e8db2512fb4c453c0d1c0d188e6cc5349
Parents: a6a428a
Author: Alexander Rukletsov <ru...@gmail.com>
Authored: Tue Apr 12 12:34:05 2016 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Tue Apr 12 12:34:05 2016 +0200

----------------------------------------------------------------------
 src/cli/execute.cpp | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/81a1d82e/src/cli/execute.cpp
----------------------------------------------------------------------
diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp
index 51fb96a..88e36b6 100644
--- a/src/cli/execute.cpp
+++ b/src/cli/execute.cpp
@@ -84,11 +84,11 @@ public:
   {
     add(&master,
         "master",
-        "Mesos master (e.g., IP1:PORT1)");
+        "Mesos master (e.g., IP:PORT).");
 
     add(&name,
         "name",
-        "Name for the command");
+        "Name for the command.");
 
     add(&shell,
         "shell",
@@ -96,67 +96,68 @@ public:
         "treated as executable value and arguments (TODO).",
         true);
 
+    // TODO(alexr): Once MESOS-4882 lands, elaborate on what `command` can
+    // mean: an executable, a shell command, an entrypoint for a container.
     add(&command,
         "command",
-        "Shell command to launch");
+        "Command to launch.");
 
     add(&environment,
         "env",
         "Shell command environment variables.\n"
-        "The value could be a JSON formatted string of environment variables"
-        "(ie: {\"name1\": \"value1\"} )\n"
-        "or a file path containing the JSON formatted environment variables.\n"
-        "Path could be of the form 'file:///path/to/file' "
-        "or '/path/to/file'.\n");
+        "The value could be a JSON formatted string of environment variables\n"
+        "(i.e., {\"name1\": \"value1\"}) or a file path containing the JSON\n"
+        "formatted environment variables. Path should be of the form\n"
+        "'file:///path/to/file'.");
 
     add(&resources,
         "resources",
-        "Resources for the command",
+        "Resources for the command.",
         "cpus:1;mem:128");
 
     add(&hadoop,
         "hadoop",
-        "Path to `hadoop' script (used for copying packages)",
+        "Path to 'hadoop' script (used for copying packages).",
         "hadoop");
 
     add(&hdfs,
         "hdfs",
-        "The ip:port of the NameNode service",
+        "The ip:port of the NameNode service.",
         "localhost:9000");
 
     add(&package,
         "package",
         "Package to upload into HDFS and copy into command's\n"
-        "working directory (requires `hadoop', see --hadoop)");
+        "working directory (requires 'hadoop', see --hadoop).");
 
     add(&overwrite,
         "overwrite",
-        "Overwrite the package in HDFS if it already exists",
+        "Overwrite the package in HDFS if it already exists.",
         false);
 
     add(&checkpoint,
         "checkpoint",
-        "Enable checkpointing for the framework",
+        "Enable checkpointing for the framework.",
         false);
 
     add(&appc_image,
         "appc_image",
-        "Appc image name that follows the Appc spec"
-        "(e.g, ubuntu, example.com/reduce-worker)");
+        "Appc image name that follows the Appc spec\n"
+        "(e.g., ubuntu, example.com/reduce-worker).");
 
     add(&docker_image,
         "docker_image",
-        "Docker image that follows the Docker CLI naming <image>:<tag>"
-        "(ie: ubuntu, busybox:latest).");
+        "Docker image that follows the Docker CLI naming <image>:<tag>\n"
+        "(i.e., ubuntu, busybox:latest).");
 
     add(&containerizer,
         "containerizer",
-        "Containerizer to be used (ie: docker, mesos)",
+        "Containerizer to be used (i.e., docker, mesos).",
         "mesos");
 
     add(&role,
         "role",
-        "Role to use when registering",
+        "Role to use when registering.",
         "*");
   }
 
@@ -539,7 +540,7 @@ int main(int argc, char** argv)
 {
   Flags flags;
 
-  // Load flags from environment and command line.
+  // Load flags from command line only.
   Try<Nothing> load = flags.load(None(), argc, argv);
 
   if (load.isError()) {