This is an automated email from the ASF dual-hosted git repository. bennoe pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit fb37ddaa847b12a139e4fcb1d107a923e1355cff Author: Benno Evers <[email protected]> AuthorDate: Fri Nov 8 14:03:40 2019 +0100 Consolidated 'Master::authorizeReserveResources' overloads. Removed one overload of `authorizeReserveResources()` that was not being used anywhere. Review: https://reviews.apache.org/r/71699/ --- src/master/master.cpp | 18 +++++------------- src/master/master.hpp | 6 ------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/master/master.cpp b/src/master/master.cpp index 2fdd6f7..bbbc076 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -3753,16 +3753,6 @@ Future<bool> Master::authorizeReserveResources( const Offer::Operation::Reserve& reserve, const Option<Principal>& principal) { - // Authorizing the reserve operation is equivalent to authorizing - // the resources specified in the operation. - return authorizeReserveResources(reserve.resources(), principal); -} - - -Future<bool> Master::authorizeReserveResources( - const Resources& resources, - const Option<Principal>& principal) -{ if (authorizer.isNone()) { return true; // Authorization is disabled. } @@ -3780,7 +3770,7 @@ Future<bool> Master::authorizeReserveResources( // Add an element to `request.roles` for each unique role in the resources. hashset<string> roles; vector<Future<bool>> authorizations; - foreach (const Resource& resource, resources) { + foreach (const Resource& resource, reserve.resources()) { // NOTE: We rely on the master to ensure that the resource is in the // post-reservation-refinement format. If there is a stack of reservations, // we perform authorization for the role of the most refined reservation, @@ -3810,7 +3800,7 @@ Future<bool> Master::authorizeReserveResources( LOG(INFO) << "Authorizing principal '" << (principal.isSome() ? stringify(principal.get()) : "ANY") - << "' to reserve resources '" << resources << "'"; + << "' to reserve resources '" << reserve.resources() << "'"; // NOTE: Empty authorizations are not valid and are checked by a validator. // However under certain circumstances, this method can be called before @@ -4213,8 +4203,10 @@ Future<bool> Master::authorizeSlave( // agent's principal and authorizing them helps prevent agents from // advertising reserved resources of arbitrary roles. if (!Resources(slaveInfo.resources()).reserved().empty()) { + Offer::Operation::Reserve reserve; + reserve.mutable_resources()->CopyFrom(slaveInfo.resources()); authorizations.push_back( - authorizeReserveResources(slaveInfo.resources(), principal)); + authorizeReserveResources(reserve, principal)); } return authorization::collectAuthorizations(authorizations); diff --git a/src/master/master.hpp b/src/master/master.hpp index dc45028..d2392d7 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -779,12 +779,6 @@ protected: const Offer::Operation::Reserve& reserve, const Option<process::http::authentication::Principal>& principal); - // Authorizes whether the provided `principal` is allowed to reserve - // the specified `resources`. - process::Future<bool> authorizeReserveResources( - const Resources& resources, - const Option<process::http::authentication::Principal>& principal); - /** * Authorizes an `UNRESERVE` operation. *
