multiple booking for one

This commit is contained in:
mr 2024-11-18 15:49:40 +01:00
parent 9a8625f8b4
commit 902ad0ea71

View File

@ -3,6 +3,7 @@ package workflow
import ( import (
"errors" "errors"
"fmt" "fmt"
"slices"
"strings" "strings"
"cloud.o-forge.io/core/oc-lib/dbs" "cloud.o-forge.io/core/oc-lib/dbs"
@ -126,8 +127,13 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
} }
if g != nil && g.Links != nil && len(g.Links) > 0 { // if the graph is set and has links then book the workflow (even on ourselves) if g != nil && g.Links != nil && len(g.Links) > 0 { // if the graph is set and has links then book the workflow (even on ourselves)
accessor := (&compute.ComputeResource{}).GetAccessor(nil) accessor := (&compute.ComputeResource{}).GetAccessor(nil)
isDCFound := []string{}
for _, link := range g.Links { for _, link := range g.Links {
if ok, dc_id := realData.isDCLink(link); ok { // check if the link is a link between a compute and a resource booking is only on compute if ok, dc_id := realData.isDCLink(link); ok { // check if the link is a link between a compute and a resource booking is only on compute
if slices.Contains(isDCFound, dc_id) {
continue
} // if the compute is already found, skip it
isDCFound = append(isDCFound, dc_id)
dc, code, _ := accessor.LoadOne(dc_id) dc, code, _ := accessor.LoadOne(dc_id)
if code != 200 { if code != 200 {
continue continue