Validates that the `gpus` resource is not fractional. We rely on scalar resources only having 3 digits of precision.
| 322 | // Validates that the `gpus` resource is not fractional. |
| 323 | // We rely on scalar resources only having 3 digits of precision. |
| 324 | Option<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 | |
| 335 | Option<Error> validateHealthCheck(const HealthCheck& healthCheck) |