correction planner
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/booking"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
@@ -77,6 +78,12 @@ func generate(request *tools.APIRequest, shallow bool) (*Planner, error) {
|
||||
for _, b := range bookings {
|
||||
bk := b.(*booking.Booking)
|
||||
|
||||
// Skip terminal bookings — they no longer occupy capacity.
|
||||
switch bk.State {
|
||||
case enum.SUCCESS, enum.FAILURE, enum.FORGOTTEN, enum.CANCELLED:
|
||||
continue
|
||||
}
|
||||
|
||||
// Only compute and storage resources are eligible
|
||||
if bk.ResourceType != tools.COMPUTE_RESOURCE && bk.ResourceType != tools.STORAGE_RESOURCE {
|
||||
continue
|
||||
@@ -147,6 +154,10 @@ func (p *Planner) Check(resourceID string, instanceID string, req *ResourceReque
|
||||
if !slot.Start.Before(*end) || !slot.End.After(start) {
|
||||
continue
|
||||
}
|
||||
// If capacity is unknown (reqPct empty), any overlap blocks the slot.
|
||||
if len(reqPct) == 0 {
|
||||
return false
|
||||
}
|
||||
// Combined usage must not exceed 100 % for any requested dimension
|
||||
for dim, needed := range reqPct {
|
||||
if slot.Usage[dim]+needed > 100.0 {
|
||||
|
||||
Reference in New Issue
Block a user