correction planner
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/models/booking"
|
"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/models/resources"
|
||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"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 {
|
for _, b := range bookings {
|
||||||
bk := b.(*booking.Booking)
|
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
|
// Only compute and storage resources are eligible
|
||||||
if bk.ResourceType != tools.COMPUTE_RESOURCE && bk.ResourceType != tools.STORAGE_RESOURCE {
|
if bk.ResourceType != tools.COMPUTE_RESOURCE && bk.ResourceType != tools.STORAGE_RESOURCE {
|
||||||
continue
|
continue
|
||||||
@@ -147,6 +154,10 @@ func (p *Planner) Check(resourceID string, instanceID string, req *ResourceReque
|
|||||||
if !slot.Start.Before(*end) || !slot.End.After(start) {
|
if !slot.Start.Before(*end) || !slot.End.After(start) {
|
||||||
continue
|
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
|
// Combined usage must not exceed 100 % for any requested dimension
|
||||||
for dim, needed := range reqPct {
|
for dim, needed := range reqPct {
|
||||||
if slot.Usage[dim]+needed > 100.0 {
|
if slot.Usage[dim]+needed > 100.0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user