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 2017/05/04 19:27:24 UTC
[2/2] mesos git commit: Exposed full unreserved resources in /slaves
endpoint on master.
Exposed full unreserved resources in /slaves endpoint on master.
The JSON key for this information is "unreserved_resources_full".
Review: https://reviews.apache.org/r/58940
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d032764c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d032764c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d032764c
Branch: refs/heads/master
Commit: d032764c3c16f9c2c1b1d8ce76ed1abac7276f63
Parents: e8fefea
Author: Vinod Kone <vi...@gmail.com>
Authored: Tue May 2 16:21:08 2017 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Thu May 4 12:26:40 2017 -0700
----------------------------------------------------------------------
src/master/http.cpp | 11 +++++
src/tests/persistent_volume_endpoints_tests.cpp | 51 +++++++++++++++++++-
2 files changed, 60 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d032764c/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 5aae528..e2590a1 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -2374,6 +2374,17 @@ Future<Response> Master::Http::slaves(
}
});
+
+ Resources unreservedResources = slave->totalResources.unreserved();
+
+ writer->field(
+ "unreserved_resources_full",
+ [&unreservedResources](JSON::ArrayWriter* writer) {
+ foreach (const Resource& resource, unreservedResources) {
+ writer->element(JSON::Protobuf(resource));
+ }
+ });
+
Resources usedResources = Resources::sum(slave->usedResources);
writer->field(
http://git-wip-us.apache.org/repos/asf/mesos/blob/d032764c/src/tests/persistent_volume_endpoints_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_endpoints_tests.cpp b/src/tests/persistent_volume_endpoints_tests.cpp
index 1237d08..8c54372 100644
--- a/src/tests/persistent_volume_endpoints_tests.cpp
+++ b/src/tests/persistent_volume_endpoints_tests.cpp
@@ -1960,8 +1960,8 @@ TEST_F(PersistentVolumeEndpointsTest, ReserveAndSlaveRemoval)
}
-// This tests that dynamic reservations and persistent volumes are
-// reflected in the "/slaves" master endpoint.
+// This tests that unreserved resources, dynamic reservations and persistent
+// volumes are reflected in the "/slaves" master endpoint.
TEST_F(PersistentVolumeEndpointsTest, SlavesEndpointFullResources)
{
TestAllocator<> allocator;
@@ -2154,6 +2154,50 @@ TEST_F(PersistentVolumeEndpointsTest, SlavesEndpointFullResources)
ASSERT_SOME(expectedReserved);
+ Try<JSON::Value> expectedUnreserved = JSON::parse(
+ R"~(
+ [
+ {
+ "name": "cpus",
+ "role": "*",
+ "scalar": {
+ "value": 3.0
+ },
+ "type": "SCALAR"
+ },
+ {
+ "name": "mem",
+ "role": "*",
+ "scalar": {
+ "value": 1536.0
+ },
+ "type": "SCALAR"
+ },
+ {
+ "name": "disk",
+ "role": "*",
+ "scalar": {
+ "value": 3072.0
+ },
+ "type": "SCALAR"
+ },
+ {
+ "name": "ports",
+ "ranges": {
+ "range": [
+ {
+ "begin": 31000,
+ "end": 32000
+ }
+ ]
+ },
+ "role": "*",
+ "type": "RANGES"
+ }
+ ])~");
+
+ ASSERT_SOME(expectedUnreserved);
+
Try<JSON::Value> expectedUsed = JSON::parse(
R"~(
[
@@ -2300,6 +2344,9 @@ TEST_F(PersistentVolumeEndpointsTest, SlavesEndpointFullResources)
JSON::Value reservedValue = slaveObject.values["reserved_resources_full"];
EXPECT_EQ(expectedReserved.get(), reservedValue);
+ JSON::Value unreservedValue = slaveObject.values["unreserved_resources_full"];
+ EXPECT_EQ(expectedUnreserved.get(), unreservedValue);
+
JSON::Value usedValue = slaveObject.values["used_resources_full"];
EXPECT_EQ(expectedUsed.get(), usedValue);