| 699 | |
| 700 | |
| 701 | void CheckerProcess::__nestedCommandCheck( |
| 702 | shared_ptr<Promise<int>> promise, |
| 703 | http::Connection connection, |
| 704 | check::Command cmd, |
| 705 | runtime::Nested nested) |
| 706 | { |
| 707 | ContainerID checkContainerId; |
| 708 | checkContainerId.set_value("check-" + id::UUID::random().toString()); |
| 709 | checkContainerId.mutable_parent()->CopyFrom(nested.taskContainerId); |
| 710 | |
| 711 | previousCheckContainerId = checkContainerId; |
| 712 | |
| 713 | CommandInfo command(cmd.info); |
| 714 | |
| 715 | agent::Call call; |
| 716 | call.set_type(agent::Call::LAUNCH_NESTED_CONTAINER_SESSION); |
| 717 | |
| 718 | agent::Call::LaunchNestedContainerSession* launch = |
| 719 | call.mutable_launch_nested_container_session(); |
| 720 | |
| 721 | launch->mutable_container_id()->CopyFrom(checkContainerId); |
| 722 | launch->mutable_command()->CopyFrom(command); |
| 723 | |
| 724 | http::Request request; |
| 725 | request.method = "POST"; |
| 726 | request.url = nested.agentURL; |
| 727 | request.body = serialize(ContentType::PROTOBUF, evolve(call)); |
| 728 | request.headers = {{"Accept", stringify(ContentType::RECORDIO)}, |
| 729 | {"Message-Accept", stringify(ContentType::PROTOBUF)}, |
| 730 | {"Content-Type", stringify(ContentType::PROTOBUF)}}; |
| 731 | |
| 732 | if (nested.authorizationHeader.isSome()) { |
| 733 | request.headers["Authorization"] = nested.authorizationHeader.get(); |
| 734 | } |
| 735 | |
| 736 | // TODO(alexr): Use a lambda named capture for |
| 737 | // this cached value once it is available. |
| 738 | const Duration timeout = checkTimeout; |
| 739 | |
| 740 | auto checkTimedOut = std::make_shared<bool>(false); |
| 741 | |
| 742 | // `LAUNCH_NESTED_CONTAINER_SESSION` returns a streamed response with |
| 743 | // the output of the container. The agent will close the stream once |
| 744 | // the container has exited, or kill the container if the client |
| 745 | // closes the connection. |
| 746 | // |
| 747 | // We're calling `Connection::send` with `streamed = false`, so that |
| 748 | // it returns an HTTP response of type 'BODY' once the entire response |
| 749 | // is received. |
| 750 | // |
| 751 | // This means that this future will not be completed until after the |
| 752 | // check command has finished or the connection has been closed. |
| 753 | // |
| 754 | // TODO(gkleiman): The output of timed-out checks is lost, we'll |
| 755 | // probably have to call `Connection::send` with `streamed = true` |
| 756 | // to be able to log it. See MESOS-7903. |
| 757 | connection.send(request, false) |
| 758 | .after(checkTimeout, |
nothing calls this directly
no test coverage detected