simplify processing check up
This commit is contained in:
parent
3cb536d2e3
commit
6e732e3eac
BIN
oc-monitord
BIN
oc-monitord
Binary file not shown.
@ -7,18 +7,20 @@ package workflow_builder
|
||||
import (
|
||||
. "oc-monitord/models"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resource_model"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph"
|
||||
w "cloud.o-forge.io/core/oc-lib/models/workflow"
|
||||
"github.com/nwtgck/go-fakelish"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type ArgoBuilder struct {
|
||||
graph graph.Graph
|
||||
OriginWorkflow w.Workflow
|
||||
Workflow Workflow
|
||||
Timeout int
|
||||
}
|
||||
@ -137,11 +139,11 @@ func (b *ArgoBuilder) createVolumes() {
|
||||
}
|
||||
|
||||
func (b *ArgoBuilder) getDependency(current_computing_id string) (dependencies []string) {
|
||||
for _, link := range b.graph.Links {
|
||||
if !b.IsProcessing(link.Source.ID) || !b.IsProcessing(link.Destination.ID) {
|
||||
for _, link := range b.OriginWorkflow.Graph.Links {
|
||||
if !b.IsProcessing(link.Source.ID) {
|
||||
continue
|
||||
}
|
||||
source := b.graph.Items[link.Source.ID].Processing
|
||||
source := b.OriginWorkflow.Graph.Items[link.Source.ID].Processing
|
||||
if current_computing_id == link.Destination.ID && source != nil {
|
||||
dependency_name := getArgoName(source.GetName(), link.Source.ID)
|
||||
dependencies = append(dependencies, dependency_name)
|
||||
@ -239,7 +241,7 @@ func removeImageName(user_input string) string {
|
||||
|
||||
// Return the graphItem containing a Processing resource, so that we have access to the ID of the graphItem in order to identify it in the links
|
||||
func (b *ArgoBuilder) getProcessings() (list_computings []graph.GraphItem) {
|
||||
for _, item := range b.graph.Items {
|
||||
for _, item := range b.OriginWorkflow.Graph.Items {
|
||||
if item.Processing != nil {
|
||||
list_computings = append(list_computings, item)
|
||||
}
|
||||
@ -248,12 +250,7 @@ func (b *ArgoBuilder) getProcessings() (list_computings []graph.GraphItem) {
|
||||
}
|
||||
|
||||
func (b *ArgoBuilder) IsProcessing(id string) bool {
|
||||
for _, item := range b.graph.Items {
|
||||
if item.Processing != nil && item.Processing.GetID() == id {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(b.OriginWorkflow.Processings, id)
|
||||
}
|
||||
|
||||
func getStringValue(comp resource_model.AbstractResource, key string) string {
|
||||
|
@ -46,7 +46,7 @@ func (w *WorflowDB) ExportToArgo(timeout int) (string, error) {
|
||||
return "", fmt.Errorf("can't export a graph that has not been loaded yet")
|
||||
}
|
||||
|
||||
argo_builder := ArgoBuilder{graph: *w.Workflow.Graph, Timeout: timeout}
|
||||
argo_builder := ArgoBuilder{OriginWorkflow: *w.Workflow, Timeout: timeout}
|
||||
filename, err := argo_builder.CreateDAG()
|
||||
if err != nil {
|
||||
logger.Error().Msg("Could not create the argo file for " + w.Workflow.Name)
|
||||
|
Loading…
Reference in New Issue
Block a user