18321: Account for CUDA in container reuse
[arvados.git] / services / api / app / models / container_request.rb
index 4a580816cd737674966781d63dfee9a1b4a1dbee..00773fcb86818f057170700ba3ab79e157307bb6 100644 (file)
@@ -336,6 +336,22 @@ class ContainerRequest < ArvadosModel
                      "[#{k}]=#{v.inspect} must be a positive integer")
         end
       end
+      if runtime_constraints['cuda']
+        ['device_count'].each do |k|
+          v = runtime_constraints['cuda'][k]
+          if !v.is_a?(Integer) || v < 0
+            errors.add(:runtime_constraints,
+                       "[cuda.#{k}]=#{v.inspect} must be a positive or zero integer")
+          end
+        end
+        ['driver_version', 'hardware_capability'].each do |k|
+          v = runtime_constraints['cuda'][k]
+          if !v.is_a?(String)
+            errors.add(:runtime_constraints,
+                       "[cuda.#{k}]=#{v.inspect} must be a string")
+          end
+        end
+      end
     end
   end