| 4205 | |
| 4206 | |
| 4207 | Future<Response> Http::launchNestedContainerSession( |
| 4208 | const mesos::agent::Call& call, |
| 4209 | const RequestMediaTypes& mediaTypes, |
| 4210 | const Option<Principal>& principal) const |
| 4211 | { |
| 4212 | CHECK_EQ(mesos::agent::Call::LAUNCH_NESTED_CONTAINER_SESSION, call.type()); |
| 4213 | CHECK(call.has_launch_nested_container_session()); |
| 4214 | |
| 4215 | LOG(INFO) << "Processing LAUNCH_NESTED_CONTAINER_SESSION call for container '" |
| 4216 | << call.launch_nested_container_session().container_id() << "'"; |
| 4217 | |
| 4218 | // Helper to destroy the container. |
| 4219 | auto destroy = [this](const ContainerID& containerId) { |
| 4220 | slave->containerizer->destroy(containerId) |
| 4221 | .onFailed([containerId](const string& failure) { |
| 4222 | LOG(ERROR) << "Failed to destroy nested container " |
| 4223 | << containerId << ": " << failure; |
| 4224 | }); |
| 4225 | }; |
| 4226 | |
| 4227 | return ObjectApprovers::create( |
| 4228 | slave->authorizer, |
| 4229 | principal, |
| 4230 | {LAUNCH_NESTED_CONTAINER_SESSION}) |
| 4231 | .then(defer( |
| 4232 | slave->self(), |
| 4233 | [=](const Owned<ObjectApprovers>& approvers) { |
| 4234 | return _launchContainer<LAUNCH_NESTED_CONTAINER_SESSION>( |
| 4235 | call.launch_nested_container_session().container_id(), |
| 4236 | call.launch_nested_container_session().command(), |
| 4237 | None(), |
| 4238 | None(), |
| 4239 | call.launch_nested_container_session().has_container() |
| 4240 | ? call.launch_nested_container_session().container() |
| 4241 | : Option<ContainerInfo>::none(), |
| 4242 | ContainerClass::DEBUG, |
| 4243 | mediaTypes.accept, |
| 4244 | approvers); |
| 4245 | })) |
| 4246 | .then(defer( |
| 4247 | slave->self(), |
| 4248 | [=](const Response& response) -> Future<Response> { |
| 4249 | // If `response` has failed or is not `OK`, the container will be |
| 4250 | // destroyed by `_launchContainer`. |
| 4251 | const ContainerID& containerId = |
| 4252 | call.launch_nested_container_session().container_id(); |
| 4253 | |
| 4254 | if (response.status != OK().status) { |
| 4255 | return response; |
| 4256 | } |
| 4257 | |
| 4258 | // If launch is successful, attach to the container output. |
| 4259 | mesos::agent::Call call; |
| 4260 | call.set_type(mesos::agent::Call::ATTACH_CONTAINER_OUTPUT); |
| 4261 | call.mutable_attach_container_output()->mutable_container_id() |
| 4262 | ->CopyFrom(containerId); |
| 4263 | |
| 4264 | // Instead of directly returning the response of `attachContainerOutput` |
nothing calls this directly
no test coverage detected