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 1d225b4c0270f06b901f0fafd777a347aae921cd Author: Benno Evers <[email protected]> AuthorDate: Fri Nov 8 14:19:11 2019 +0100 Updated 'getResourceConversion()' for reservation updates. Updated the `getResourcesConversion()` function to correctly handle the `source` field in `RESERVE` operations. Review: https://reviews.apache.org/r/71719/ --- src/common/resources_utils.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/resources_utils.cpp b/src/common/resources_utils.cpp index 4c958c8..17cc96d 100644 --- a/src/common/resources_utils.cpp +++ b/src/common/resources_utils.cpp @@ -119,11 +119,20 @@ Try<vector<TResourceConversion>> getResourceConversions( return Error("Operation not supported"); case TOperation::RESERVE: { - foreach (const TResource& reserved, operation.reserve().resources()) { - // Note that we only allow "pushing" a single reservation at time. - TResources consumed = TResources(reserved).popReservation(); - conversions.emplace_back(consumed, reserved); + TResources reserved(operation.reserve().resources()); + + // If the operation explicitly specifies a `source` we use that, + // otherwise we assume that the operation is "pushing" a single + // reservation. At this point, the resources in the operation + // should have been already sanity checked, so we don't have to + // repeat that here. + TResources consumed; + if (operation.reserve().source_size() > 0) { + consumed = TResources(operation.reserve().source()); + } else { + consumed = reserved.popReservation(); } + conversions.emplace_back(consumed, reserved); break; }
