MCPcopy Create free account
hub / github.com/apache/mesos / create

Method create

src/docker/docker.cpp:119–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117
118
119Try<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
164void commandDiscarded(const Subprocess& s, const string& cmd)

Callers

nothing calls this directly

Calls 15

is_absoluteFunction · 0.85
NoneClass · 0.85
ImageClass · 0.85
maxFunction · 0.85
MegabytesFunction · 0.85
calculateOOMScoreAdjFunction · 0.85
validateVersionMethod · 0.80
usMethod · 0.80
atMethod · 0.80
imageMethod · 0.80
ContainerClass · 0.70
foreachFunction · 0.70

Tested by

no test coverage detected