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

Method unreserve

src/master/http.cpp:4059–4129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4057
4058
4059Future<Response> Master::Http::unreserve(
4060 const Request& request,
4061 const Option<Principal>& principal) const
4062{
4063 // TODO(greggomann): Remove this check once the `Principal` type is used in
4064 // `ReservationInfo`, `DiskInfo`, and within the master's `principals` map.
4065 // See MESOS-7202.
4066 if (principal.isSome() && principal->value.isNone()) {
4067 return Forbidden(
4068 "The request's authenticated principal contains claims, but no value "
4069 "string. The master currently requires that principals have a value");
4070 }
4071
4072 // When current master is not the leader, redirect to the leading master.
4073 if (!master->elected()) {
4074 return redirect(request);
4075 }
4076
4077 if (request.method != "POST") {
4078 return MethodNotAllowed({"POST"}, request.method);
4079 }
4080
4081 // Parse the query string in the request body.
4082 Try<hashmap<string, string>> decode =
4083 process::http::query::decode(request.body);
4084
4085 if (decode.isError()) {
4086 return BadRequest("Unable to decode query string: " + decode.error());
4087 }
4088
4089 const hashmap<string, string>& values = decode.get();
4090
4091 Option<string> value;
4092
4093 value = values.get("slaveId");
4094 if (value.isNone()) {
4095 return BadRequest("Missing 'slaveId' query parameter in the request body");
4096 }
4097
4098 SlaveID slaveId;
4099 slaveId.set_value(value.get());
4100
4101 value = values.get("resources");
4102 if (value.isNone()) {
4103 return BadRequest(
4104 "Missing 'resources' query parameter in the request body");
4105 }
4106
4107 Try<JSON::Array> parse =
4108 JSON::parse<JSON::Array>(value.get());
4109
4110 if (parse.isError()) {
4111 return BadRequest(
4112 "Error in parsing 'resources' query parameter in the request body: " +
4113 parse.error());
4114 }
4115
4116 RepeatedPtrField<Resource> resources;

Callers 7

getOperationMessageMethod · 0.45
TESTFunction · 0.45
getResourceProviderIdFunction · 0.45
_unreserveMethod · 0.45
initializeMethod · 0.45
foreachFunction · 0.45

Calls 11

ForbiddenClass · 0.85
redirectFunction · 0.85
MethodNotAllowedClass · 0.85
BadRequestClass · 0.85
electedMethod · 0.80
errorMethod · 0.65
decodeFunction · 0.50
isSomeMethod · 0.45
isNoneMethod · 0.45
isErrorMethod · 0.45
getMethod · 0.45

Tested by 2

getOperationMessageMethod · 0.36
TESTFunction · 0.36