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 <[email protected]> Authored: Tue May 2 16:28:03 2017 -0700 Committer: Vinod Kone <[email protected]> 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 {
