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

Method launchNestedContainerSession

src/slave/http.cpp:4207–4347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4205
4206
4207Future<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`

Callers

nothing calls this directly

Calls 15

deferFunction · 0.85
NoneClass · 0.85
OKClass · 0.85
destroyFunction · 0.85
typeMethod · 0.80
commandMethod · 0.80
CopyFromMethod · 0.80
writerMethod · 0.80
readerMethod · 0.80
isDiscardedMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80

Tested by

no test coverage detected