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

Method getOperations

src/slave/http.cpp:2006–2058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2004
2005
2006Future<Response> Http::getOperations(
2007 const mesos::agent::Call& call,
2008 ContentType acceptType,
2009 const Option<Principal>& principal) const
2010{
2011 CHECK_EQ(mesos::agent::Call::GET_OPERATIONS, call.type());
2012
2013 LOG(INFO) << "Processing GET_OPERATIONS call";
2014
2015 return ObjectApprovers::create(slave->authorizer, principal, {VIEW_ROLE})
2016 .then(defer(
2017 slave->self(),
2018 [=](const Owned<ObjectApprovers>& approvers) -> Response {
2019 // We consider a principal to be authorized to view an operation if it
2020 // is authorized to view the resources the operation is performed on.
2021 auto approved = [&approvers](const Operation& operation) {
2022 Try<Resources> consumedResources =
2023 protobuf::getConsumedResources(operation.info());
2024
2025 if (consumedResources.isError()) {
2026 LOG(WARNING)
2027 << "Could not approve operation " << operation.uuid()
2028 << " since its consumed resources could not be determined: "
2029 << consumedResources.error();
2030
2031 return false;
2032 }
2033
2034 foreach (const Resource& resource, consumedResources.get()) {
2035 if (!approvers->approved<VIEW_ROLE>(resource)) {
2036 return false;
2037 }
2038 }
2039
2040 return true;
2041 };
2042
2043 agent::Response response;
2044 response.set_type(mesos::agent::Response::GET_OPERATIONS);
2045
2046 agent::Response::GetOperations* operations =
2047 response.mutable_get_operations();
2048
2049 foreachvalue (Operation* operation, slave->operations) {
2050 if (approved(*operation)) {
2051 operations->add_operations()->CopyFrom(*operation);
2052 }
2053 }
2054
2055 return OK(
2056 serialize(acceptType, evolve(response)), stringify(acceptType));
2057 }));
2058}
2059
2060
2061Future<Response> Http::getTasks(

Callers

nothing calls this directly

Calls 15

deferFunction · 0.85
getConsumedResourcesFunction · 0.85
OKClass · 0.85
typeMethod · 0.80
infoMethod · 0.80
CopyFromMethod · 0.80
foreachvalueFunction · 0.70
errorMethod · 0.65
createFunction · 0.50
serializeFunction · 0.50
evolveFunction · 0.50
stringifyFunction · 0.50

Tested by

no test coverage detected