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:23 UTC
[1/2] mesos git commit: Exposed full unreserved resources in /state
endpoint on agent.
Repository: mesos
Updated Branches:
refs/heads/master e8fefeab7 -> f158e03bb
Exposed full unreserved resources in /state endpoint on agent.
The JSON key for this information is "unreserved_resources_full".
Review: https://reviews.apache.org/r/58941
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f158e03b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f158e03b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f158e03b
Branch: refs/heads/master
Commit: f158e03bb1764becbca26f03dde0da5d89fd86ac
Parents: d032764
Author: Vinod Kone <vi...@gmail.com>
Authored: Tue May 2 16:28:03 2017 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Thu May 4 12:26:40 2017 -0700
----------------------------------------------------------------------
src/slave/http.cpp | 8 ++++
src/tests/reservation_endpoints_tests.cpp | 52 ++++++++++++++++++++++++--
2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f158e03b/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 2ce345d..5beaf91 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -1300,6 +1300,14 @@ Future<Response> Slave::Http::state(
}
});
+ writer->field(
+ "unreserved_resources_full",
+ [&totalResources](JSON::ArrayWriter* writer) {
+ foreach (const Resource& resource, totalResources.unreserved()) {
+ writer->element(JSON::Protobuf(resource));
+ }
+ });
+
writer->field("attributes", Attributes(slave->info.attributes()));
if (slave->master.isSome()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/f158e03b/src/tests/reservation_endpoints_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/reservation_endpoints_tests.cpp b/src/tests/reservation_endpoints_tests.cpp
index cc8499a..8c195eb 100644
--- a/src/tests/reservation_endpoints_tests.cpp
+++ b/src/tests/reservation_endpoints_tests.cpp
@@ -1632,9 +1632,9 @@ TEST_F(ReservationEndpointsTest, DifferentPrincipalsSameRole)
}
-// This test verifies that dynamic reservations are reflected in the
-// agent's "/state" endpoint. Separately exposing reservations from
-// the agent's endpoint is necessary because it's not a guarantee that
+// This test verifies that unreserved resources and dynamic reservations are
+// reflected in the agent's "/state" endpoint. Separately exposing reservations
+// from the agent's endpoint is necessary because it's not a guarantee that
// it matches the master's versions.
TEST_F(ReservationEndpointsTest, AgentStateEndpointResources)
{
@@ -1775,6 +1775,52 @@ TEST_F(ReservationEndpointsTest, AgentStateEndpointResources)
EXPECT_EQ(expected, state.values["reserved_resources_full"]);
}
+
+ {
+ JSON::Value expected = 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"
+ }
+ ])~").get();
+
+ EXPECT_EQ(expected, state.values["unreserved_resources_full"]);
+ }
}
} // namespace tests {
[2/2] mesos git commit: Exposed full unreserved resources in /slaves
endpoint on master.
Posted by vi...@apache.org.
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);