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

Function validateGpus

src/common/validation.cpp:324–332  ·  view source on GitHub ↗

Validates that the `gpus` resource is not fractional. We rely on scalar resources only having 3 digits of precision.

Source from the content-addressed store, hash-verified

322// Validates that the `gpus` resource is not fractional.
323// We rely on scalar resources only having 3 digits of precision.
324Option<Error> validateGpus(const RepeatedPtrField<Resource>& resources)
325{
326 double gpus = Resources(resources).gpus().getOrElse(0.0);
327 if (static_cast<long long>(gpus * 1000.0) % 1000 != 0) {
328 return Error("The 'gpus' resource must be an unsigned integer");
329 }
330
331 return None();
332}
333
334
335Option<Error> validateHealthCheck(const HealthCheck& healthCheck)

Callers 2

validateFunction · 0.85
validateFunction · 0.85

Calls 5

NoneClass · 0.85
getOrElseMethod · 0.80
ResourcesClass · 0.70
ErrorFunction · 0.50
gpusMethod · 0.45

Tested by

no test coverage detected