| 3545 | |
| 3546 | template <authorization::Action action> |
| 3547 | Future<Response> Http::_waitContainer( |
| 3548 | const ContainerID& containerId, |
| 3549 | ContentType acceptType, |
| 3550 | const Owned<ObjectApprovers>& approvers, |
| 3551 | const bool deprecated) const |
| 3552 | { |
| 3553 | // Attempt to get the executor associated with this ContainerID. |
| 3554 | // We only expect to get the executor when waiting upon a nested container |
| 3555 | // under a container launched via a scheduler. In other cases, we are |
| 3556 | // waiting on a standalone container (possibly nested). |
| 3557 | Executor* executor = slave->getExecutor(containerId); |
| 3558 | if (executor == nullptr) { |
| 3559 | if (!approvers->approved<action>(containerId)) { |
| 3560 | return Forbidden(); |
| 3561 | } |
| 3562 | } else { |
| 3563 | Framework* framework = slave->getFramework(executor->frameworkId); |
| 3564 | CHECK_NOTNULL(framework); |
| 3565 | |
| 3566 | if (!approvers->approved<action>( |
| 3567 | executor->info, framework->info, containerId)) { |
| 3568 | return Forbidden(); |
| 3569 | } |
| 3570 | } |
| 3571 | |
| 3572 | return slave->containerizer->wait(containerId) |
| 3573 | .then([=](const Option<ContainerTermination>& termination) -> Response { |
| 3574 | if (termination.isNone()) { |
| 3575 | return NotFound( |
| 3576 | "Container " + stringify(containerId) + " cannot be found"); |
| 3577 | } |
| 3578 | |
| 3579 | mesos::agent::Response response; |
| 3580 | |
| 3581 | // The response object depends on which API was originally used |
| 3582 | // to make this call. |
| 3583 | if (deprecated) { |
| 3584 | response.set_type(mesos::agent::Response::WAIT_NESTED_CONTAINER); |
| 3585 | |
| 3586 | mesos::agent::Response::WaitNestedContainer* waitNestedContainer = |
| 3587 | response.mutable_wait_nested_container(); |
| 3588 | |
| 3589 | if (termination->has_status()) { |
| 3590 | waitNestedContainer->set_exit_status(termination->status()); |
| 3591 | } |
| 3592 | |
| 3593 | if (termination->has_state()) { |
| 3594 | waitNestedContainer->set_state(termination->state()); |
| 3595 | } |
| 3596 | |
| 3597 | if (termination->has_reason()) { |
| 3598 | waitNestedContainer->set_reason(termination->reason()); |
| 3599 | } |
| 3600 | |
| 3601 | if (!termination->limited_resources().empty()) { |
| 3602 | waitNestedContainer->mutable_limitation()->mutable_resources() |
| 3603 | ->CopyFrom(termination->limited_resources()); |
| 3604 | } |
nothing calls this directly
no test coverage detected