Divided the execution between local and container and created an interface responsible for preparing and launching the execution

This commit is contained in:
pb
2025-04-25 11:14:54 +02:00
parent b43cb6d758
commit 90fa0b8edd
5 changed files with 237 additions and 52 deletions

View File

@@ -2,7 +2,7 @@ package daemons
import (
"fmt"
"os"
"oc-schedulerd/conf"
"time"
oclib "cloud.o-forge.io/core/oc-lib"
@@ -38,22 +38,44 @@ func (em *ExecutionManager) RetrieveNextExecutions() {
func (em *ExecutionManager) executeExecution(Execution *workflow_execution.WorkflowExecution) {
// start execution
// create the yaml that describes the pod : filename, path/url to Loki
exec_method := os.Getenv("MONITOR_METHOD")
var executor Executor
// exec_method := os.Getenv("MONITOR_METHOD")
logger := oclib.GetLogger()
if exec_method == "k8s" {
logger.Error().Msg("TODO : executing oc-monitor in a k8s")
} else {
logger.Debug().Msg("Executing oc-monitor localy")
duration := 0
if Execution.EndDate != nil {
duration = int(Execution.EndDate.Sub(Execution.ExecDate).Seconds())
}
monitor := LocalMonitor{
Logger: logger,
Duration: duration,
ExecutionID: Execution.ExecutionsID,
PeerID: Execution.CreatorID,
}
monitor.LaunchLocalMonitor()
duration := 0
if Execution.EndDate != nil {
duration = int(Execution.EndDate.Sub(Execution.ExecDate).Seconds())
}
if conf.GetConfig().Mode == "local" {
executor = NewLocalMonitor(Execution.ExecutionsID, Execution.CreatorID, duration)
}
if conf.GetConfig().Mode == "container" {
executor = NewContainerMonitor(Execution.ExecutionsID, Execution.CreatorID, duration)
}
if executor == nil {
logger.Fatal().Msg("Could not create logger")
}
args := executor.PrepareMonitorExec()
executor.LaunchMonitor(args,logger)
// if exec_method == "k8s" {
// logger.Error().Msg("TODO : executing oc-monitor in a k8s")
// } else {
// logger.Debug().Msg("Executing oc-monitor localy")
// duration := 0
// if Execution.EndDate != nil {
// duration = int(Execution.EndDate.Sub(Execution.ExecDate).Seconds())
// }
// monitor := LocalMonitor{
// Logger: logger,
// Duration: duration,
// ExecutionID: Execution.ExecutionsID,
// PeerID: Execution.CreatorID,
// LokiUrl: conf.GetConfig().LokiUrl,
// }
// monitor.LaunchLocalMonitor()
// }
}