You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2018/01/13 17:00:35 UTC
[2/2] mesos git commit: Added missing fields to the GET_MASTER
operator API call.
Added missing fields to the GET_MASTER operator API call.
Several fields were present in the old master '/state' endpoint
which are now not accessible via the V1 operator API. This patch
adds two such fields to the response for the GET_MASTER call.
Review: https://reviews.apache.org/r/65056/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/49598872
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/49598872
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/49598872
Branch: refs/heads/master
Commit: 4959887230a7d7c55629083be978810f48b780a3
Parents: 433a7c8
Author: Greg Mann <gr...@mesosphere.io>
Authored: Fri Jan 12 18:56:36 2018 -0800
Committer: Greg Mann <gr...@gmail.com>
Committed: Sat Jan 13 08:48:11 2018 -0800
----------------------------------------------------------------------
include/mesos/master/master.proto | 4 ++++
include/mesos/v1/master/master.proto | 4 ++++
src/master/http.cpp | 10 ++++++++--
src/tests/api_tests.cpp | 8 ++++++++
4 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/49598872/include/mesos/master/master.proto
----------------------------------------------------------------------
diff --git a/include/mesos/master/master.proto b/include/mesos/master/master.proto
index f4506fe..3e34634 100644
--- a/include/mesos/master/master.proto
+++ b/include/mesos/master/master.proto
@@ -464,6 +464,10 @@ message Response {
// Contains the master's information.
message GetMaster {
optional MasterInfo master_info = 1;
+
+ optional double start_time = 2;
+
+ optional double elected_time = 3;
}
// Contains the cluster's maintenance status.
http://git-wip-us.apache.org/repos/asf/mesos/blob/49598872/include/mesos/v1/master/master.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/master/master.proto b/include/mesos/v1/master/master.proto
index 5cb64df..6759c30 100644
--- a/include/mesos/v1/master/master.proto
+++ b/include/mesos/v1/master/master.proto
@@ -460,6 +460,10 @@ message Response {
// Contains the master's information.
message GetMaster {
optional MasterInfo master_info = 1;
+
+ optional double start_time = 2;
+
+ optional double elected_time = 3;
}
// Contains the cluster's maintenance status.
http://git-wip-us.apache.org/repos/asf/mesos/blob/49598872/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 0c2cd55..cae67b8 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -2247,8 +2247,14 @@ Future<Response> Master::Http::getMaster(
// It is guaranteed that this master has been elected as the leader.
CHECK(master->elected());
- response.mutable_get_master()->mutable_master_info()->CopyFrom(
- master->info());
+ mesos::master::Response::GetMaster* getMaster = response.mutable_get_master();
+
+ getMaster->mutable_master_info()->CopyFrom(master->info());
+
+ getMaster->set_start_time(master->startTime.secs());
+ if (master->electedTime.isSome()) {
+ getMaster->set_elected_time(master->electedTime.get().secs());
+ }
return OK(serialize(contentType, evolve(response)),
stringify(contentType));
http://git-wip-us.apache.org/repos/asf/mesos/blob/49598872/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index 28d4643..fb45879 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -1043,6 +1043,14 @@ TEST_P(MasterAPITest, GetMaster)
ASSERT_EQ(evolve(masterFlags.domain.get()), masterInfo.domain());
ASSERT_EQ(master.get()->getMasterInfo().ip(), masterInfo.ip());
+
+ const v1::master::Response::GetMaster getMaster = v1Response->get_master();
+
+ ASSERT_TRUE(getMaster.has_start_time());
+ ASSERT_TRUE(Clock::now().secs() > getMaster.start_time());
+
+ ASSERT_TRUE(getMaster.has_elected_time());
+ ASSERT_TRUE(Clock::now().secs() > getMaster.elected_time());
}