| 117 | |
| 118 | |
| 119 | Try<Owned<Docker>> Docker::create( |
| 120 | const string& path, |
| 121 | const string& socket, |
| 122 | bool validate, |
| 123 | const Option<JSON::Object>& config) |
| 124 | { |
| 125 | #ifndef __WINDOWS__ |
| 126 | // TODO(hausdorff): Currently, `path::absolute` does not handle all the edge |
| 127 | // cases of Windows. Revisit this when MESOS-3442 is resolved. |
| 128 | // |
| 129 | // NOTE: When we do come back and fix this bug, it is also worth noting that |
| 130 | // on Windows an empty value of `socket` is frequently used to connect to the |
| 131 | // Docker host (i.e., the user wants to connect 'npipes://', with an empty |
| 132 | // socket path). A full solution should accommodate this. |
| 133 | if (!path::is_absolute(socket)) { |
| 134 | return Error("Invalid Docker socket path: " + socket); |
| 135 | } |
| 136 | #endif // __WINDOWS__ |
| 137 | |
| 138 | Owned<Docker> docker(new Docker(path, socket, config)); |
| 139 | if (!validate) { |
| 140 | return docker; |
| 141 | } |
| 142 | |
| 143 | #ifdef __linux__ |
| 144 | // Make sure that cgroups are mounted, and at least the 'cpu' |
| 145 | // subsystem is attached. |
| 146 | Result<string> hierarchy = cgroups::hierarchy("cpu"); |
| 147 | |
| 148 | if (hierarchy.isNone()) { |
| 149 | return Error("Failed to find a mounted cgroups hierarchy " |
| 150 | "for the 'cpu' subsystem; you probably need " |
| 151 | "to mount cgroups manually"); |
| 152 | } |
| 153 | #endif // __linux__ |
| 154 | |
| 155 | Try<Nothing> validateVersion = docker->validateVersion(Version(1, 8, 0)); |
| 156 | if (validateVersion.isError()) { |
| 157 | return Error(validateVersion.error()); |
| 158 | } |
| 159 | |
| 160 | return docker; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | void commandDiscarded(const Subprocess& s, const string& cmd) |
nothing calls this directly
no test coverage detected