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

Method _reserve

src/master/http.cpp:1931–1971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1929
1930
1931Future<Response> Master::Http::_reserve(
1932 const SlaveID& slaveId,
1933 const RepeatedPtrField<Resource>& source,
1934 const RepeatedPtrField<Resource>& resources,
1935 const Option<Principal>& principal) const
1936{
1937 Slave* slave = master->slaves.registered.get(slaveId);
1938 if (slave == nullptr) {
1939 return BadRequest("No agent found with specified ID");
1940 }
1941
1942 // Create an operation.
1943 Offer::Operation operation;
1944 operation.set_type(Offer::Operation::RESERVE);
1945 operation.mutable_reserve()->mutable_source()->CopyFrom(source);
1946 operation.mutable_reserve()->mutable_resources()->CopyFrom(resources);
1947
1948 Option<Error> error = validateAndUpgradeResources(&operation);
1949 if (error.isSome()) {
1950 return BadRequest(error->message);
1951 }
1952
1953 error = validation::operation::validate(
1954 operation.reserve(), principal, slave->capabilities);
1955
1956 if (error.isSome()) {
1957 return BadRequest(
1958 "Invalid RESERVE operation on agent " + stringify(*slave) + ": " +
1959 error->message);
1960 }
1961
1962 return master->authorize(
1963 principal, ActionObject::reserve(operation.reserve()))
1964 .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
1965 if (!authorized) {
1966 return Forbidden();
1967 }
1968
1969 return _operation(slaveId, operation);
1970 }));
1971}
1972
1973
1974Future<Response> Master::Http::reserveResources(

Callers

nothing calls this directly

Calls 13

BadRequestClass · 0.85
deferFunction · 0.85
ForbiddenClass · 0.85
CopyFromMethod · 0.80
validateFunction · 0.70
stringifyFunction · 0.50
getMethod · 0.45
isSomeMethod · 0.45
reserveMethod · 0.45
thenMethod · 0.45
authorizeMethod · 0.45

Tested by

no test coverage detected