Repository: mesos Updated Branches: refs/heads/master 063966355 -> 536a681d3
Placed the `convertResourceFormat` calls after resource validation. `Resources` requires that the `Resource` objects being constructed with be validated and are in the "post-reservation-refinement" format. The `convertResourceFormat` was previously placed after the validation of operations, but we construct `Resources` prior to operation validation. This patch moves the conversion logic earlier to be done right after resource validation. Review: https://reviews.apache.org/r/60253 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/536a681d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/536a681d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/536a681d Branch: refs/heads/master Commit: 536a681d3555cdb5e1e0e4e3164cd842c509cd29 Parents: 0639663 Author: Michael Park <[email protected]> Authored: Tue Jun 20 14:25:31 2017 -0700 Committer: Michael Park <[email protected]> Committed: Tue Jun 20 17:59:55 2017 -0700 ---------------------------------------------------------------------- src/master/http.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/536a681d/src/master/http.cpp ---------------------------------------------------------------------- diff --git a/src/master/http.cpp b/src/master/http.cpp index 1cff814..4dd43fd 100644 --- a/src/master/http.cpp +++ b/src/master/http.cpp @@ -1096,6 +1096,8 @@ Future<Response> Master::Http::createVolumes( return BadRequest(error.get().message); } + convertResourceFormat(&volume.get(), POST_RESERVATION_REFINEMENT); + volumes += volume.get(); } @@ -1130,8 +1132,6 @@ Future<Response> Master::Http::_createVolumes( validate.get().message); } - convertResourceFormat(&operation, POST_RESERVATION_REFINEMENT); - return master->authorizeCreateVolume(operation.create(), principal) .then(defer(master->self(), [=](bool authorized) -> Future<Response> { if (!authorized) { @@ -1273,6 +1273,8 @@ Future<Response> Master::Http::destroyVolumes( return BadRequest(error.get().message); } + convertResourceFormat(&volume.get(), POST_RESERVATION_REFINEMENT); + volumes += volume.get(); } @@ -1305,8 +1307,6 @@ Future<Response> Master::Http::_destroyVolumes( return BadRequest("Invalid DESTROY operation: " + validate.get().message); } - convertResourceFormat(&operation, POST_RESERVATION_REFINEMENT); - return master->authorizeDestroyVolume(operation.destroy(), principal) .then(defer(master->self(), [=](bool authorized) -> Future<Response> { if (!authorized) { @@ -2243,6 +2243,8 @@ Future<Response> Master::Http::reserve( return BadRequest(error.get().message); } + convertResourceFormat(&resource.get(), POST_RESERVATION_REFINEMENT); + resources += resource.get(); } @@ -2274,8 +2276,6 @@ Future<Response> Master::Http::_reserve( error.get().message); } - convertResourceFormat(&operation, POST_RESERVATION_REFINEMENT); - return master->authorizeReserveResources(operation.reserve(), principal) .then(defer(master->self(), [=](bool authorized) -> Future<Response> { if (!authorized) { @@ -4992,6 +4992,8 @@ Future<Response> Master::Http::unreserve( return BadRequest(error.get().message); } + convertResourceFormat(&resource.get(), POST_RESERVATION_REFINEMENT); + resources += resource.get(); } @@ -5021,8 +5023,6 @@ Future<Response> Master::Http::_unreserve( "Invalid UNRESERVE operation: " + error.get().message); } - convertResourceFormat(&operation, POST_RESERVATION_REFINEMENT); - return master->authorizeUnreserveResources(operation.unreserve(), principal) .then(defer(master->self(), [=](bool authorized) -> Future<Response> { if (!authorized) {
