You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2019/07/11 19:45:31 UTC
[mesos] 05/05: Added reserved, offered,
allocated resources to the /roles endpoint.
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
commit 69c8feab6a62b1728872a367a8ed28f88eb029d3
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Wed Jul 10 20:09:31 2019 -0400
Added reserved, offered, allocated resources to the /roles endpoint.
This provides helpful information for debugging, as well as for the
webui to display in the roles table.
Review: https://reviews.apache.org/r/71053
---
src/master/readonly_handler.cpp | 8 ++++++++
src/tests/role_tests.cpp | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/src/master/readonly_handler.cpp b/src/master/readonly_handler.cpp
index 5f0ad1d..f4432a5 100644
--- a/src/master/readonly_handler.cpp
+++ b/src/master/readonly_handler.cpp
@@ -745,8 +745,16 @@ process::http::Response Master::ReadOnlyHandler::roles(
const ResourceQuantities offered = role.isSome() ?
(*role)->offered() : ResourceQuantities();
+ const ResourceQuantities reserved = role.isSome() ?
+ (*role)->reserved() : ResourceQuantities();
+
+ // Deprecated by allocated, offered, reserved.
writer->field("resources", allocated + offered);
+ writer->field("allocated", allocated);
+ writer->field("offered", offered);
+ writer->field("reserved", reserved);
+
if (role.isNone()) {
writer->field("frameworks", [](JSON::ArrayWriter*) {});
} else {
diff --git a/src/tests/role_tests.cpp b/src/tests/role_tests.cpp
index 01c8014..5066e41 100644
--- a/src/tests/role_tests.cpp
+++ b/src/tests/role_tests.cpp
@@ -349,6 +349,9 @@ TEST_F(RoleTest, EndpointNoFrameworks)
" \"frameworks\": [],"
" \"name\": \"*\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"*\","
" \"consumed\": {},"
@@ -361,6 +364,9 @@ TEST_F(RoleTest, EndpointNoFrameworks)
" \"frameworks\": [],"
" \"name\": \"role1\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"role1\","
" \"consumed\": {},"
@@ -373,6 +379,9 @@ TEST_F(RoleTest, EndpointNoFrameworks)
" \"frameworks\": [],"
" \"name\": \"role2\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"role2\","
" \"consumed\": {},"
@@ -603,6 +612,20 @@ TEST_F(RoleTest, RolesEndpointContainsConsumedQuota)
" \"mem\": 11110.0,"
" \"ports\": 1100.0"
" },"
+ " \"allocated\": {"
+ " \"cpus\": 11.0,"
+ " \"mem\": 110.0"
+ " },"
+ " \"offered\": {"
+ " \"cpus\": 1100.0,"
+ " \"mem\": 11000.0,"
+ " \"ports\": 1100.0"
+ " },"
+ " \"reserved\": {"
+ " \"cpus\": 101.0,"
+ " \"mem\": 1010.0,"
+ " \"ports\": 100.0"
+ " },"
" \"quota\": {"
" \"consumed\": {"
" \"cpus\": 111.0,"
@@ -687,6 +710,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesWeights)
" \"frameworks\": [\"" + frameworkId1->value() + "\"],"
" \"name\": \"roleX\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"roleX\","
" \"consumed\": {},"
@@ -699,6 +725,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesWeights)
" \"frameworks\": [],"
" \"name\": \"roleY\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"roleY\","
" \"consumed\": {},"
@@ -711,6 +740,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesWeights)
" \"frameworks\": [\"" + frameworkId2->value() + "\"],"
" \"name\": \"roleZ\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"roleZ\","
" \"consumed\": {},"
@@ -787,6 +819,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(RoleTest, EndpointImplicitRolesQuotas)
" \"frameworks\": [],"
" \"name\": \"non-existent-role\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"non-existent-role\","
" \"consumed\": {},"
@@ -888,6 +923,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(
" \"frameworks\": [\"" + frameworkId->value() + "\"],"
" \"name\": \"role1\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"role1\","
" \"consumed\": {},"
@@ -900,6 +938,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(
" \"frameworks\": [\"" + frameworkId->value() + "\"],"
" \"name\": \"role2\","
" \"resources\": {},"
+ " \"allocated\": {},"
+ " \"offered\": {},"
+ " \"reserved\": {},"
" \"quota\": {"
" \"role\": \"role2\","
" \"consumed\": {},"