From 902ad0ea714480c3604334a675198798cc9d457b Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 18 Nov 2024 15:49:40 +0100 Subject: [PATCH] multiple booking for one --- models/workflow/workflow_mongo_accessor.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index ad467c7..9930047 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -3,6 +3,7 @@ package workflow import ( "errors" "fmt" + "slices" "strings" "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) accessor := (&compute.ComputeResource{}).GetAccessor(nil) + isDCFound := []string{} 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 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) if code != 200 { continue