----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/51683/#review148302 -----------------------------------------------------------
include/mesos/resources.hpp (lines 351 - 352) <https://reviews.apache.org/r/51683/#comment215781> ``` Returns an Error when the role is invalid or the reservation is set when the role is '*'. ``` include/mesos/resources.hpp (lines 357 - 359) <https://reviews.apache.org/r/51683/#comment215782> A more concise and clear way to explain it IMO is: ``` // Equivalent to `flatten("*")` except it returns a Resources directly because the result is always a valid in this case. ``` src/cli/execute.cpp (line 377) <https://reviews.apache.org/r/51683/#comment215858> In the places where it's not **obvious** (i.e., the arguments are locally defined) that the role/reservation **must be valid**, I think we should at least use a CHECK on the result of `flatten()` instead of directly `get()`. This is probably true especially for all non-testing code. Mind do a sweep for the whole patch? src/common/resources.cpp (lines 1113 - 1121) <https://reviews.apache.org/r/51683/#comment215859> This would suffice. ``` Try<Resources> flattened = flatten("*"); CHECK_SOME(flattened); return flattened.get(); ``` - Jiang Yan Xu On Sept. 7, 2016, 11:31 p.m., Guangya Liu wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/51683/ > ----------------------------------------------------------- > > (Updated Sept. 7, 2016, 11:31 p.m.) > > > Review request for mesos, Benjamin Mahler and Jiang Yan Xu. > > > Bugs: MESOS-6131 > https://issues.apache.org/jira/browse/MESOS-6131 > > > Repository: mesos > > > Description > ------- > > 1) Previously if role or reservation info are invalid, > the result is an empty Resources object, now it returns > an error. > 2) Added a new flatten() method to flatten resources with > star role and empty reservation. > > > Diffs > ----- > > include/mesos/resources.hpp 87828aa5e4818efd40dd72dc199669281b8a15ae > include/mesos/v1/resources.hpp 27bdd275277edc60d97b720e596f21e8e8f8dc27 > src/cli/execute.cpp b752d057a3d86482ef1a4baaf31052469e38dc76 > src/common/resources.cpp 77ee92193de1f34131f7a86b7d16731c9c3e17e2 > src/examples/dynamic_reservation_framework.cpp > 850bb2a5b243dd5d5a8b6476570b4f943fde6185 > src/examples/test_framework.cpp a83766a92617d50eadd92ec55113e049a7290d03 > src/examples/test_http_framework.cpp > 441e86c88b035d9a268b8b51b95da3e1eb842a62 > src/tests/api_tests.cpp e440d1b44fb0b40dd1f68209c71e5ca0cd19f4fb > src/tests/hierarchical_allocator_tests.cpp > b2179215f3a4c2f4018670e8e54f02e06c39c3b1 > src/tests/mesos.hpp 9bcdaf19833d08ccfbfe4781179f8626e141a7e1 > src/tests/persistent_volume_endpoints_tests.cpp > 266c2a0ff4a99baa96a7c4980f076755603256a9 > src/tests/reservation_endpoints_tests.cpp > bee5ea6b3a3ee7fafb7312a6d89de79d62c57ec1 > src/tests/reservation_tests.cpp 000957826011bf28f7550a83db3e60a796162fb3 > src/tests/resources_tests.cpp f627862870279e5a778aa83e1ddcaa88c27ba1cb > src/tests/role_tests.cpp 162c9414a70723a212cfd39ac5c0b8325c3f3b5d > src/v1/resources.cpp 4ba5bf87c9b9fef67eeb447a3f3b520f1e81ad77 > > Diff: https://reviews.apache.org/r/51683/diff/ > > > Testing > ------- > > make > make check > > ``` > ./bin/mesos-tests.sh --gtest_filter="ResourcesOperationTest.FlattenResources" > [==========] Running 1 test from 1 test case. > [----------] Global test environment set-up. > [----------] 1 test from ResourcesOperationTest > [ RUN ] ResourcesOperationTest.FlattenResources > [ OK ] ResourcesOperationTest.FlattenResources (3 ms) > [----------] 1 test from ResourcesOperationTest (3 ms total) > > [----------] Global test environment tear-down > [==========] 1 test from 1 test case ran. (24 ms total) > [ PASSED ] 1 test. > ``` > > > Thanks, > > Guangya Liu > >
