This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f49e55  Implemented V0 UPDATE_FRAMEWORK call in the master.
3f49e55 is described below

commit 3f49e5543df1a0d5ed8381389fb1ebbe515c9934
Author: Andrei Sekretenko <[email protected]>
AuthorDate: Thu Jun 6 17:29:48 2019 -0400

    Implemented V0 UPDATE_FRAMEWORK call in the master.
    
    Implements the UPDATE_FRAMEWORK call in the V0 scheduler API.
    To help keep consistency between V1 and V0 APIs, the V0 call is
    implemented as a wrapper around V1 call, which converts HTTP
    responses with 4xx status codes into FrameworkErrorMessage.
    
    Review: https://reviews.apache.org/r/70751/
---
 src/master/master.cpp | 24 ++++++++++++++++++++----
 src/master/master.hpp |  7 +++++++
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/master/master.cpp b/src/master/master.cpp
index b3c10ab..cb7c902 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -2491,10 +2491,7 @@ void Master::receive(
       break;
 
     case scheduler::Call::UPDATE_FRAMEWORK:
-      drop(
-          from,
-          call,
-          "'UPDATE_FRAMEWORK' is not supported by the v0 API");
+      updateFramework(from, std::move(*call.mutable_update_framework()));
       break;
 
     case scheduler::Call::UNKNOWN:
@@ -3157,6 +3154,25 @@ void Master::_subscribe(
 }
 
 
+void Master::updateFramework(
+    const process::UPID& from,
+    mesos::scheduler::Call::UpdateFramework&& call)
+{
+  FrameworkID frameworkId = call.framework_info().id();
+
+  updateFramework(std::move(call))
+    .onAny([this, from, frameworkId](
+             const Future<process::http::Response>& response) {
+      if (response->code != process::http::Status::OK) {
+        CHECK_EQ(response->type, process::http::Response::BODY);
+        FrameworkErrorMessage message;
+        message.set_message(response->body);
+        send(from, message);
+      }
+    });
+}
+
+
 Future<process::http::Response> Master::updateFramework(
     mesos::scheduler::Call::UpdateFramework&& call)
 {
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 3504bd3..7acaa82 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1055,6 +1055,13 @@ private:
       google::protobuf::RepeatedPtrField<std::string>&& suppressedRoles,
       const process::Future<bool>& authorized);
 
+  // Update framework via SchedulerDriver (i.e. no response
+  // code feedback, FrameworkErrorMessage on error).
+  void updateFramework(
+      const process::UPID& from,
+      mesos::scheduler::Call::UpdateFramework&& call);
+
+  // Update framework via HTTP API (i.e. returns 200 OK).
   process::Future<process::http::Response> updateFramework(
       mesos::scheduler::Call::UpdateFramework&& call);
 

Reply via email to