You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2015/05/12 01:39:01 UTC

[2/2] mesos git commit: Added /master/teardown endpoint that is going to replace /master/shutdown endpoint.

Added /master/teardown endpoint that is going to replace
/master/shutdown endpoint.

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


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

Branch: refs/heads/master
Commit: b2b03f220df8960ecfa0242c5efb304b1c07b8b9
Parents: 496aac3
Author: Vinod Kone <vi...@gmail.com>
Authored: Tue May 5 16:45:25 2015 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Mon May 11 16:32:35 2015 -0700

----------------------------------------------------------------------
 src/master/http.cpp   | 32 +++++++++++++++++++++++---------
 src/master/master.cpp | 12 +++++++++++-
 src/master/master.hpp |  9 +++++----
 3 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b2b03f22/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index acc85b6..7fa47a9 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -862,16 +862,30 @@ Future<Response> Master::Http::roles(const Request& request) const
 
 const string Master::Http::SHUTDOWN_HELP = HELP(
     TLDR(
-        "Shuts down a running framework."),
+        "Shuts down a running framework by shutting down all tasks/executors "
+        "and removing the framework."),
     USAGE(
         "/master/shutdown"),
     DESCRIPTION(
-        "Please provide a \"frameworkId\" value designating the ",
-        "running framework to shut down.",
+        "NOTE: This endpoint is deprecated in favor of /master/teardown.",
+        "Please provide a \"frameworkId\" value designating the running "
+        "framework to shut down.",
         "Returns 200 OK if the framework was correctly shutdown."));
 
 
-Future<Response> Master::Http::shutdown(const Request& request) const
+const string Master::Http::TEARDOWN_HELP = HELP(
+    TLDR(
+        "Tears down a running framework by shutting down all tasks/executors "
+        "and removing the framework."),
+    USAGE(
+        "/master/teardown"),
+    DESCRIPTION(
+        "Please provide a \"frameworkId\" value designating the running "
+        "framework to tear down.",
+        "Returns 200 OK if the framework was correctly teared down."));
+
+
+Future<Response> Master::Http::teardown(const Request& request) const
 {
   if (request.method != "POST") {
     return BadRequest("Expecting POST");
@@ -909,7 +923,7 @@ Future<Response> Master::Http::shutdown(const Request& request) const
 
   // Skip authorization if no ACLs were provided to the master.
   if (master->authorizer.isNone()) {
-    return _shutdown(id);
+    return _teardown(id);
   }
 
   mesos::ACL::ShutdownFramework shutdown;
@@ -927,15 +941,15 @@ Future<Response> Master::Http::shutdown(const Request& request) const
     shutdown.mutable_framework_principals()->set_type(ACL::Entity::ANY);
   }
 
-  lambda::function<Future<Response>(bool)> _shutdown =
-    lambda::bind(&Master::Http::_shutdown, this, id, lambda::_1);
+  lambda::function<Future<Response>(bool)> _teardown =
+    lambda::bind(&Master::Http::_teardown, this, id, lambda::_1);
 
   return master->authorizer.get()->authorize(shutdown)
-    .then(defer(master->self(), _shutdown));
+    .then(defer(master->self(), _teardown));
 }
 
 
-Future<Response> Master::Http::_shutdown(
+Future<Response> Master::Http::_teardown(
     const FrameworkID& id,
     bool authorized) const
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/b2b03f22/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 4ad683e..ec32cd6 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -747,12 +747,22 @@ void Master::initialize()
           Http::log(request);
           return http.roles(request);
         });
+
+  // TODO(vinod): "/shutdown" endpoint is deprecated in favor of
+  // "/teardown". Remove this endpoint in 0.24.0.
   route("/shutdown",
         Http::SHUTDOWN_HELP,
         [http](const http::Request& request) {
           Http::log(request);
-          return http.shutdown(request);
+          return http.teardown(request);
         });
+  route("/teardown",
+        Http::TEARDOWN_HELP,
+        [http](const http::Request& request) {
+          Http::log(request);
+          return http.teardown(request);
+        });
+
   route("/slaves",
         Http::SLAVES_HELP,
         [http](const http::Request& request) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/b2b03f22/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index ee53dfb..af41216 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -497,8 +497,8 @@ private:
     process::Future<process::http::Response> roles(
         const process::http::Request& request) const;
 
-    // /master/shutdown
-    process::Future<process::http::Response> shutdown(
+    // /master/teardown and /master/shutdown (deprecated).
+    process::Future<process::http::Response> teardown(
         const process::http::Request& request) const;
 
     // /master/slaves
@@ -520,7 +520,8 @@ private:
     const static std::string HEALTH_HELP;
     const static std::string OBSERVE_HELP;
     const static std::string REDIRECT_HELP;
-    const static std::string SHUTDOWN_HELP;
+    const static std::string SHUTDOWN_HELP;  // Deprecated.
+    const static std::string TEARDOWN_HELP;
     const static std::string SLAVES_HELP;
     const static std::string TASKS_HELP;
 
@@ -532,7 +533,7 @@ private:
         const process::http::Request& request) const;
 
     // Continuations.
-    process::Future<process::http::Response> _shutdown(
+    process::Future<process::http::Response> _teardown(
         const FrameworkID& id,
         bool authorized = true) const;