2024-07-29 15:46:44 +02:00
|
|
|
package daemons
|
|
|
|
|
2024-08-09 18:44:33 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"oc-scheduler/logger"
|
|
|
|
"os/exec"
|
|
|
|
)
|
2024-07-29 15:46:44 +02:00
|
|
|
|
|
|
|
type LocalMonitor struct{
|
2024-08-09 18:44:33 +02:00
|
|
|
LokiURL string
|
|
|
|
KubeURL string
|
|
|
|
WorkflowName string
|
2024-07-29 15:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (lm *LocalMonitor) LaunchLocalMonitor (){
|
2024-08-09 18:44:33 +02:00
|
|
|
if (lm.LokiURL == "" || lm.KubeURL == "" || lm.WorkflowName == ""){
|
2024-07-29 15:46:44 +02:00
|
|
|
logger.Logger.Error().Msg("Missing parameter in LocalMonitor")
|
|
|
|
}
|
|
|
|
|
|
|
|
// For dev purposes, in prod KubeURL must be a kube API's URL
|
|
|
|
if(lm.KubeURL == "localhost"){
|
2024-08-09 18:44:33 +02:00
|
|
|
lm.execLocalKube()
|
2024-07-29 15:46:44 +02:00
|
|
|
} else{
|
2024-08-09 18:44:33 +02:00
|
|
|
lm.execRemoteKube()
|
2024-07-29 15:46:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-09 18:44:33 +02:00
|
|
|
func (lm *LocalMonitor) execLocalKube (){
|
2024-07-29 15:46:44 +02:00
|
|
|
// kube_url := ""
|
2024-08-09 18:44:33 +02:00
|
|
|
cmd := exec.Command("../oc-monitor/oc-monitor", "-w",lm.WorkflowName, "-u", lm.LokiURL)
|
|
|
|
// cmd_ls := exec.Command("ls", "../oc-monitor")
|
|
|
|
output, err := cmd.CombinedOutput()
|
|
|
|
// output, err := cmd_ls.CombinedOutput()
|
|
|
|
fmt.Println(string(output))
|
|
|
|
if err !=nil {
|
|
|
|
logger.Logger.Error().Msg("Could not start oc-monitor for " + lm.WorkflowName + " : " + err.Error())
|
|
|
|
}
|
|
|
|
|
2024-07-29 15:46:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-08-09 18:44:33 +02:00
|
|
|
func (lm *LocalMonitor) execRemoteKube (){
|
2024-07-29 15:46:44 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (lm *LocalMonitor) todo (){
|
|
|
|
|
|
|
|
}
|