MCPcopy Create free account
hub / github.com/apache/mesos / _unreserve

Method _unreserve

src/master/http.cpp:4132–4166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4130
4131
4132Future<Response> Master::Http::_unreserve(
4133 const SlaveID& slaveId,
4134 const RepeatedPtrField<Resource>& resources,
4135 const Option<Principal>& principal) const
4136{
4137 Slave* slave = master->slaves.registered.get(slaveId);
4138 if (slave == nullptr) {
4139 return BadRequest("No agent found with specified ID");
4140 }
4141
4142 // Create an operation.
4143 Offer::Operation operation;
4144 operation.set_type(Offer::Operation::UNRESERVE);
4145 operation.mutable_unreserve()->mutable_resources()->CopyFrom(resources);
4146
4147 Option<Error> error = validateAndUpgradeResources(&operation);
4148 if (error.isSome()) {
4149 return BadRequest(error->message);
4150 }
4151
4152 error = validation::operation::validate(operation.unreserve());
4153 if (error.isSome()) {
4154 return BadRequest("Invalid UNRESERVE operation: " + error->message);
4155 }
4156
4157 return master->authorize(
4158 principal, ActionObject::unreserve(operation.unreserve()))
4159 .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
4160 if (!authorized) {
4161 return Forbidden();
4162 }
4163
4164 return _operation(slaveId, operation);
4165 }));
4166}
4167
4168
4169Future<Response> Master::Http::_operation(

Callers

nothing calls this directly

Calls 12

BadRequestClass · 0.85
deferFunction · 0.85
ForbiddenClass · 0.85
CopyFromMethod · 0.80
validateFunction · 0.70
getMethod · 0.45
isSomeMethod · 0.45
unreserveMethod · 0.45
thenMethod · 0.45
authorizeMethod · 0.45
selfMethod · 0.45

Tested by

no test coverage detected