| 461 | |
| 462 | |
| 463 | Future<hashmap<ContainerID, Option<ContainerStatus>>> |
| 464 | ServiceManagerProcess::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 | |
| 515 | Future<Nothing> ServiceManagerProcess::waitContainer( |
nothing calls this directly
no test coverage detected