| 405 | } |
| 406 | |
| 407 | Option<Error> runNetNamespaceCheck(const Owned<Docker>& docker) |
| 408 | { |
| 409 | const string image = |
| 410 | string(mesos::internal::checks::DOCKER_HEALTH_CHECK_IMAGE); |
| 411 | |
| 412 | // Use `os::system` here because `docker->inspect()` only works on |
| 413 | // containers even though `docker inspect` cli command works on images. |
| 414 | const Option<int> res = os::system(strings::join( |
| 415 | " ", |
| 416 | docker->getPath(), |
| 417 | "-H", |
| 418 | docker->getSocket(), |
| 419 | "inspect", |
| 420 | image, |
| 421 | "> NUL")); |
| 422 | |
| 423 | if (res != 0) { |
| 424 | return Error("Cannot find " + image); |
| 425 | } |
| 426 | |
| 427 | // Launch two containers. One with regular network settings and the |
| 428 | // other with "--network=container:<ID>" to enter the first container's |
| 429 | // namespace. |
| 430 | const string container1 = id::UUID::random().toString(); |
| 431 | const string container2 = id::UUID::random().toString(); |
| 432 | |
| 433 | Future<Nothing> containers = |
| 434 | launchContainer(docker, container1, "nat", image) |
| 435 | .then(process::defer([=]() { |
| 436 | return launchContainer( |
| 437 | docker, container2, "container:" + container1, image) |
| 438 | .then(lambda::bind(&Docker::rm, docker, container2, true)) |
| 439 | .onAny(lambda::bind(&Docker::rm, docker, container1, true)); |
| 440 | })); |
| 441 | |
| 442 | // A minute should be enough for both containers to lauch and delete. |
| 443 | containers.await(Minutes(1)); |
| 444 | |
| 445 | if (containers.isFailed()) { |
| 446 | return Error("Failed to launch containers: " + containers.failure()); |
| 447 | } else if (!containers.isReady()) { |
| 448 | return Error("Container launch timed out"); |
| 449 | } |
| 450 | |
| 451 | return None(); |
| 452 | } |
| 453 | #endif // __WINDOWS__ |
| 454 | |
| 455 | Option<Error> dockerError; |
nothing calls this directly
no test coverage detected