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

Method growVolume

src/master/http.cpp:1074–1134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1072
1073
1074Future<Response> Master::Http::growVolume(
1075 const mesos::master::Call& call,
1076 const Option<Principal>& principal,
1077 ContentType /*contentType*/) const
1078{
1079 // TODO(greggomann): Remove this check once the `Principal` type is used in
1080 // `ReservationInfo`, `DiskInfo`, and within the master's `principals` map.
1081 // See MESOS-7202.
1082 if (principal.isSome() && principal->value.isNone()) {
1083 return Forbidden(
1084 "The request's authenticated principal contains claims, but no value "
1085 "string. The master currently requires that principals have a value");
1086 }
1087
1088 CHECK_EQ(mesos::master::Call::GROW_VOLUME, call.type());
1089 CHECK(call.has_grow_volume());
1090
1091 // Only agent default resources are supported right now.
1092 CHECK(call.grow_volume().has_slave_id());
1093
1094 const SlaveID& slaveId = call.grow_volume().slave_id();
1095
1096 Slave* slave = master->slaves.registered.get(slaveId);
1097 if (slave == nullptr) {
1098 return BadRequest("No agent found with specified ID");
1099 }
1100
1101 // Create an operation.
1102 Offer::Operation operation;
1103 operation.set_type(Offer::Operation::GROW_VOLUME);
1104
1105 operation.mutable_grow_volume()->mutable_volume()->CopyFrom(
1106 call.grow_volume().volume());
1107
1108 operation.mutable_grow_volume()->mutable_addition()->CopyFrom(
1109 call.grow_volume().addition());
1110
1111 Option<Error> error = validateAndUpgradeResources(&operation);
1112 if (error.isSome()) {
1113 return BadRequest(error->message);
1114 }
1115
1116 error = validation::operation::validate(
1117 operation.grow_volume(), slave->capabilities);
1118
1119 if (error.isSome()) {
1120 return BadRequest(
1121 "Invalid GROW_VOLUME operation on agent " +
1122 stringify(*slave) + ": " + error->message);
1123 }
1124
1125 return master->authorize(
1126 principal, ActionObject::growVolume(operation.grow_volume()))
1127 .then(defer(master->self(), [=](bool authorized) -> Future<Response> {
1128 if (!authorized) {
1129 return Forbidden();
1130 }
1131

Callers

nothing calls this directly

Calls 14

ForbiddenClass · 0.85
BadRequestClass · 0.85
deferFunction · 0.85
typeMethod · 0.80
CopyFromMethod · 0.80
validateFunction · 0.70
stringifyFunction · 0.50
isSomeMethod · 0.45
isNoneMethod · 0.45
getMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected