This commit is contained in:
mr
2024-11-07 13:36:28 +01:00
parent 310395f869
commit 92ae269685
8 changed files with 97 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ import (
"time"
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/models/resources/compute"
"cloud.o-forge.io/core/oc-lib/models/resources/processing"
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
w "cloud.o-forge.io/core/oc-lib/models/workflow"
@@ -180,6 +181,18 @@ func (b *ArgoBuilder) createTemplates() ([]string, []string, []VolumeMount) {
return firstItems, lastItems, volumes
}
func (b *ArgoBuilder) getAllComputeFromProcessing(p *processing.ProcessingResource) []*compute.ComputeResource {
computeResources := []*compute.ComputeResource{}
for _, link := range b.OriginWorkflow.Graph.Links {
if link.Source.ID == p.GetID() && b.OriginWorkflow.Graph.Items[link.Destination.ID].Compute != nil {
computeResources = append(computeResources, b.OriginWorkflow.Graph.Items[link.Destination.ID].Compute)
} else if link.Destination.ID == p.GetID() && b.OriginWorkflow.Graph.Items[link.Source.ID].Compute != nil {
computeResources = append(computeResources, b.OriginWorkflow.Graph.Items[link.Source.ID].Compute)
}
}
return computeResources
}
func (b *ArgoBuilder) createArgoTemplates(id string,
processing *processing.ProcessingResource,
volumes []VolumeMount,
@@ -188,10 +201,12 @@ func (b *ArgoBuilder) createArgoTemplates(id string,
_, firstItems, lastItems = b.addTaskToArgo(b.Workflow.getDag(), id, processing, firstItems, lastItems)
template := &Template{Name: getArgoName(processing.GetName(), id)}
template.CreateContainer(processing, b.Workflow.getDag())
if len(processing.Expose) > 0 {
// get datacenter from the processing
computes := b.getAllComputeFromProcessing(processing)
for _, compute := range computes {
b.CreateService(id, processing)
template.Metadata.Labels = make(map[string]string)
template.Metadata.Labels["app"] = "oc-service" // Construct the template for the k8s service and add a link in graph between k8s service and processing
template.Metadata.Labels["app"] = "oc-service-" + processing.GetName() + "-" + compute.GetName() // Construct the template for the k8s service and add a link in graph between k8s service and processing
}
storages := b.OriginWorkflow.GetStoragesByRelatedProcessing(id)
for _, storage := range storages {