This commit is contained in:
mr
2025-04-28 14:01:57 +02:00
parent 83d118fb05
commit 93f3806b86
4 changed files with 86 additions and 82 deletions

View File

@@ -25,11 +25,11 @@ import (
var logger zerolog.Logger
type ArgoBuilder struct {
OriginWorkflow *w.Workflow
Workflow Workflow
Services []*Service
Timeout int
RemotePeers []string
OriginWorkflow *w.Workflow
Workflow Workflow
Services []*Service
Timeout int
RemotePeers []string
}
type Workflow struct {
@@ -188,7 +188,7 @@ func (b *ArgoBuilder) createArgoTemplates(namespace string,
_, firstItems, lastItems = b.addTaskToArgo(b.Workflow.getDag(), id, processing, firstItems, lastItems)
template := &Template{Name: getArgoName(processing.GetName(), id)}
fmt.Println("Creating template for", template.Name)
isReparted, peerId := b.isProcessingReparted(*processing,id)
isReparted, peerId := b.isProcessingReparted(*processing, id)
template.CreateContainer(processing, b.Workflow.getDag())
if isReparted {
b.RemotePeers = append(b.RemotePeers, peerId)
@@ -377,20 +377,19 @@ func getArgoName(raw_name string, component_id string) (formatedName string) {
// Verify if a processing resource is attached to another Compute than the one hosting
// the current Open Cloud instance. If true return the peer ID to contact
func (b *ArgoBuilder) isProcessingReparted(processing resources.ProcessingResource, graphID string) (bool,string) {
func (b *ArgoBuilder) isProcessingReparted(processing resources.ProcessingResource, graphID string) (bool, string) {
computeAttached := b.retrieveProcessingCompute(graphID)
if computeAttached == nil {
logger.Error().Msg("No compute was found attached to processing " + processing.Name + " : " + processing.UUID )
logger.Error().Msg("No compute was found attached to processing " + processing.Name + " : " + processing.UUID)
panic(0)
}
// Creates an accessor srtictly for Peer Collection
req := oclib.NewRequest(oclib.LibDataEnum(oclib.PEER),"","",nil,nil)
// Creates an accessor srtictly for Peer Collection
req := oclib.NewRequest(oclib.LibDataEnum(oclib.PEER), "", "", nil, nil)
if req == nil {
fmt.Println("TODO : handle error when trying to create a request on the Peer Collection")
return false, ""
}
}
res := req.LoadOne(computeAttached.CreatorID)
if res.Err != "" {
@@ -398,22 +397,22 @@ func (b *ArgoBuilder) isProcessingReparted(processing resources.ProcessingResour
fmt.Print(res.Err)
return false, ""
}
peer := *res.ToPeer()
isNotReparted, _ := peer.IsMySelf()
fmt.Println("Result IsMySelf for ", peer.UUID ," : ", isNotReparted)
isNotReparted := peer.State == 1
fmt.Println("Result IsMySelf for ", peer.UUID, " : ", isNotReparted)
return !isNotReparted, peer.UUID
}
func (b *ArgoBuilder) retrieveProcessingCompute(graphID string) *resources.ComputeResource {
for _, link := range b.OriginWorkflow.Graph.Links {
// If a link contains the id of the processing
var oppositeId string
if link.Source.ID == graphID{
var oppositeId string
if link.Source.ID == graphID {
oppositeId = link.Destination.ID
} else if(link.Destination.ID == graphID){
} else if link.Destination.ID == graphID {
oppositeId = link.Source.ID
}
fmt.Println("OppositeId : ", oppositeId)
@@ -427,10 +426,9 @@ func (b *ArgoBuilder) retrieveProcessingCompute(graphID string) *resources.Compu
}
}
return nil
}
return nil
}
// Execute the last actions once the YAML file for the Argo Workflow is created
func (b *ArgoBuilder) CompleteBuild(executionsId string) error {
@@ -438,7 +436,7 @@ func (b *ArgoBuilder) CompleteBuild(executionsId string) error {
for _, peer := range b.RemotePeers {
fmt.Println("DEV :: Launching Admiralty Setup for ", peer)
setter := AdmiraltySetter{Id: executionsId}
setter.InitializeAdmiralty(conf.GetConfig().PeerID,peer)
setter.InitializeAdmiralty(conf.GetConfig().PeerID, peer)
}
return nil
}
}