| 115 | |
| 116 | |
| 117 | void ContainerDaemonProcess::launchContainer() |
| 118 | { |
| 119 | const ContainerID& containerId = launchCall.launch_container().container_id(); |
| 120 | |
| 121 | LOG(INFO) << "Launching container '" << containerId << "'"; |
| 122 | |
| 123 | http::post( |
| 124 | agentUrl, |
| 125 | getAuthHeader(authToken), |
| 126 | serialize(contentType, evolve(launchCall)), |
| 127 | stringify(contentType)) |
| 128 | .then(defer(self(), [=]( |
| 129 | const http::Response& response) -> Future<Nothing> { |
| 130 | if (response.status != http::OK().status && |
| 131 | response.status != http::Accepted().status) { |
| 132 | return Failure( |
| 133 | "Failed to launch container '" + |
| 134 | stringify(launchCall.launch_container().container_id()) + |
| 135 | "': Unexpected response '" + response.status + "' (" + |
| 136 | response.body + ")"); |
| 137 | } |
| 138 | |
| 139 | if (postStartHook.isSome()) { |
| 140 | LOG(INFO) |
| 141 | << "Invoking post-start hook for container '" << containerId << "'"; |
| 142 | |
| 143 | return postStartHook.get()(); |
| 144 | } |
| 145 | |
| 146 | return Nothing(); |
| 147 | })) |
| 148 | .onReady(defer(self(), &Self::waitContainer)) |
| 149 | .onFailed(defer(self(), [=](const string& failure) { |
| 150 | LOG(ERROR) |
| 151 | << "Failed to launch container '" |
| 152 | << launchCall.launch_container().container_id() << "': " << failure; |
| 153 | |
| 154 | terminated.fail(failure); |
| 155 | })) |
| 156 | .onDiscarded(defer(self(), [=] { |
| 157 | LOG(ERROR) |
| 158 | << "Failed to launch container '" |
| 159 | << launchCall.launch_container().container_id() |
| 160 | << "': future discarded"; |
| 161 | |
| 162 | terminated.discard(); |
| 163 | })); |
| 164 | } |
| 165 | |
| 166 | |
| 167 | void ContainerDaemonProcess::waitContainer() |
nothing calls this directly
no test coverage detected