| 165 | |
| 166 | |
| 167 | void ContainerDaemonProcess::waitContainer() |
| 168 | { |
| 169 | const ContainerID& containerId = waitCall.wait_container().container_id(); |
| 170 | |
| 171 | LOG(INFO) << "Waiting for container '" << containerId << "'"; |
| 172 | |
| 173 | http::post( |
| 174 | agentUrl, |
| 175 | getAuthHeader(authToken), |
| 176 | serialize(contentType, evolve(waitCall)), |
| 177 | stringify(contentType)) |
| 178 | .then(defer(self(), [=](const http::Response& response) -> Future<Nothing> { |
| 179 | if (response.status != http::OK().status && |
| 180 | response.status != http::NotFound().status) { |
| 181 | return Failure( |
| 182 | "Failed to wait for container '" + |
| 183 | stringify(waitCall.wait_container().container_id()) + |
| 184 | "': Unexpected response '" + response.status + "' (" + |
| 185 | response.body + ")"); |
| 186 | } |
| 187 | |
| 188 | if (postStopHook.isSome()) { |
| 189 | LOG(INFO) |
| 190 | << "Invoking post-stop hook for container '" << containerId << "'"; |
| 191 | |
| 192 | return postStopHook.get()(); |
| 193 | } |
| 194 | |
| 195 | return Nothing(); |
| 196 | })) |
| 197 | .onReady(defer(self(), &Self::launchContainer)) |
| 198 | .onFailed(defer(self(), [=](const string& failure) { |
| 199 | LOG(ERROR) |
| 200 | << "Failed to wait for container '" |
| 201 | << waitCall.wait_container().container_id() << "': " << failure; |
| 202 | |
| 203 | terminated.fail(failure); |
| 204 | })) |
| 205 | .onDiscarded(defer(self(), [=] { |
| 206 | LOG(ERROR) |
| 207 | << "Failed to wait for container '" |
| 208 | << waitCall.wait_container().container_id() << "': future discarded"; |
| 209 | |
| 210 | terminated.discard(); |
| 211 | })); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | Try<Owned<ContainerDaemon>> ContainerDaemon::create( |
nothing calls this directly
no test coverage detected