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

Method getContainers

src/csi/service_manager.cpp:463–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461
462
463Future<hashmap<ContainerID, Option<ContainerStatus>>>
464ServiceManagerProcess::getContainers()
465{
466 agent::Call call;
467 call.set_type(agent::Call::GET_CONTAINERS);
468 call.mutable_get_containers()->set_show_nested(false);
469 call.mutable_get_containers()->set_show_standalone(true);
470
471 return http::post(
472 agentUrl,
473 headers,
474 internal::serialize(contentType, internal::evolve(call)),
475 stringify(contentType))
476 .then(process::defer(self(), [this](const http::Response& httpResponse)
477 -> Future<hashmap<ContainerID, Option<ContainerStatus>>> {
478 if (httpResponse.status != http::OK().status) {
479 return Failure(
480 "Failed to get containers: Unexpected response '" +
481 httpResponse.status + "' (" + httpResponse.body + ")");
482 }
483
484 Try<mesos::v1::agent::Response> v1Response =
485 internal::deserialize<mesos::v1::agent::Response>(
486 contentType, httpResponse.body);
487
488 if (v1Response.isError()) {
489 return Failure("Failed to get containers: " + v1Response.error());
490 }
491
492 hashmap<ContainerID, Option<ContainerStatus>> result;
493
494 agent::Response response = internal::devolve(v1Response.get());
495 foreach (const agent::Response::GetContainers::Container& container,
496 response.get_containers().containers()) {
497 // Container IDs of this CSI plugin must contain the given prefix. See
498 // `LocalResourceProvider::principal` for details.
499 if (!strings::startsWith(
500 container.container_id().value(), containerPrefix)) {
501 continue;
502 }
503
504 result.put(
505 container.container_id(),
506 container.has_container_status() ? container.container_status()
507 : Option<ContainerStatus>::none());
508 }
509
510 return std::move(result);
511 }));
512}
513
514
515Future<Nothing> ServiceManagerProcess::waitContainer(

Callers

nothing calls this directly

Calls 12

deferFunction · 0.85
OKClass · 0.85
FailureClass · 0.85
evolveFunction · 0.70
devolveFunction · 0.70
errorMethod · 0.65
postFunction · 0.50
serializeFunction · 0.50
stringifyFunction · 0.50
thenMethod · 0.45
isErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected