Repository: mesos Updated Branches: refs/heads/master e95dda149 -> b05e2f0bb
Added implementation for DESTROY operation. Review: https://reviews.apache.org/r/30644 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b05e2f0b Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b05e2f0b Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b05e2f0b Branch: refs/heads/master Commit: b05e2f0bbd3447df21ad183a061a73c5d481464e Parents: 9ef2e50 Author: Jie Yu <[email protected]> Authored: Wed Feb 4 15:45:24 2015 -0800 Committer: Jie Yu <[email protected]> Committed: Wed Feb 4 16:04:17 2015 -0800 ---------------------------------------------------------------------- src/master/master.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/b05e2f0b/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index f4b6463..46caa55 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -2292,8 +2292,29 @@ void Master::_accept( } case Offer::Operation::DESTROY: { - // TODO(jieyu): Provide implementation for DESTROY. - drop(framework, operation, "Unimplemented"); + Option<Error> error = validation::operation::validate( + operation.destroy(), + slave->checkpointedResources); + + if (error.isSome()) { + drop(framework, operation, error.get().message); + continue; + } + + Try<Resources> resources = _offeredResources.apply(operation); + if (resources.isError()) { + drop(framework, operation, error.get().message); + continue; + } + + _offeredResources = resources.get(); + + allocator->updateAllocation( + frameworkId, + slaveId, + {operation}); + + updateCheckpointedResources(slave, operation); break; } @@ -4640,9 +4661,12 @@ void Master::updateCheckpointedResources( } case Offer::Operation::DESTROY: { - // TODO(jieyu): Provide implementation. - LOG(ERROR) << "Failed to update checkpointed resources for slave " - << *slave << ": Unimplemented DESTROY operation"; + Resources volumes = operation.destroy().volumes(); + + CHECK(slave->checkpointedResources.contains(volumes)) + << "Not expecting unknown persistent volumes"; + + slave->checkpointedResources -= volumes; break; }
