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

Function validateContainerInfo

src/common/validation.cpp:279–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277
278
279Option<Error> validateContainerInfo(const ContainerInfo& containerInfo)
280{
281 Option<Error> unionError = protobuf::validateProtobufUnion(containerInfo);
282 if (unionError.isSome()) {
283 // TODO(josephw): There is not enough information in this function to
284 // print an actionable warning. Readers of this warning will not know
285 // which container (task or executor) has this problem. Printing
286 // the entire ContainerInfo is the best we can do.
287 LOG(WARNING)
288 << "Invalid protobuf union detected in the given ContainerInfo ("
289 << containerInfo.DebugString()
290 << "): " << unionError.get();
291 }
292
293 foreach (const Volume& volume, containerInfo.volumes()) {
294 Option<Error> error = validateVolume(volume);
295 if (error.isSome()) {
296 return Error("Invalid volume: " + error->message);
297 }
298 }
299
300 if (containerInfo.type() == ContainerInfo::DOCKER) {
301 if (!containerInfo.has_docker()) {
302 return Error(
303 "DockerInfo 'docker' is not set for DOCKER typed ContainerInfo");
304 }
305
306 // We do not support setting `name` parameter in Docker info because
307 // Docker containerizer has its own way to name the Docker container,
308 // otherwise Docker containerizer will not be able to recognize the
309 // created container, see MESOS-8497 for details.
310 foreach (const Parameter& parameter,
311 containerInfo.docker().parameters()) {
312 if (parameter.key() == "name") {
313 return Error("Parameter in DockerInfo must not be 'name'");
314 }
315 }
316 }
317
318 return None();
319}
320
321
322// Validates that the `gpus` resource is not fractional.

Callers 1

validateFunction · 0.50

Calls 6

validateProtobufUnionFunction · 0.85
NoneClass · 0.85
typeMethod · 0.80
ErrorFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected