@@ -245,33 +245,50 @@ func (o *order) shouldBid(group *types.DeploymentGroup) bool {
245
245
var (
246
246
cpu int64
247
247
mem int64
248
+ disk int64
248
249
price int64
249
250
)
250
251
for _ , rg := range group .GetResources () {
251
252
cpu += int64 (rg .Unit .CPU * rg .Count )
252
253
mem += int64 (rg .Unit .Memory * uint64 (rg .Count ))
254
+ disk += int64 (rg .Unit .Disk * uint64 (rg .Count ))
253
255
price += int64 (rg .Price )
254
256
}
255
257
256
258
// requesting too much cpu?
257
- if cpu > int64 ( o .config .FulfillmentCPUMax ) || cpu <= 0 {
259
+ if cpu > o .config .FulfillmentCPUMax || cpu <= 0 {
258
260
o .log .Info ("unable to fulfill: cpu request too high" ,
259
261
"cpu-requested" , cpu )
260
262
return false
261
263
}
262
264
265
+ // requesting too much memory?
266
+ if mem > o .config .FulfillmentMemoryMax || mem <= 0 {
267
+ o .log .Info ("unable to fulfill: memory request too high" ,
268
+ "memory-requested" , mem )
269
+ return false
270
+ }
271
+
272
+ // requesting too much disk?
273
+ if disk > o .config .FulfillmentDiskMax || disk <= 0 {
274
+ o .log .Info ("unable to fulfill: disk request too high" ,
275
+ "disk-requested" , disk )
276
+ return false
277
+ }
278
+
263
279
// price max too low?
264
- if price * unit .Gi < mem * int64 ( o .config .FulfillmentMemPriceMin ) {
280
+ if price * unit .Gi < mem * o .config .FulfillmentMemPriceMin {
265
281
o .log .Info ("unable to fulfill: price too low" ,
266
282
"max-price" , price ,
267
- "min-price" , mem * int64 ( o .config .FulfillmentMemPriceMin ) / unit .Gi )
283
+ "min-price" , mem * o .config .FulfillmentMemPriceMin / unit .Gi )
268
284
return false
269
285
}
270
286
271
287
return true
272
288
}
273
289
274
290
func (o * order ) calculatePrice (resources types.ResourceList ) uint64 {
291
+
275
292
// TODO: catch overflow
276
293
var (
277
294
mem int64
0 commit comments