add timeout monitord
This commit is contained in:
16
main.go
16
main.go
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/logs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
|
||||
"github.com/akamensky/argparse"
|
||||
"github.com/google/uuid"
|
||||
@@ -78,7 +80,7 @@ func main() {
|
||||
logger.Error().Msg("Could not retrieve workflow " + conf.GetConfig().WorkflowID + " from oc-catalog API")
|
||||
}
|
||||
|
||||
argo_file_path, err := new_wf.ExportToArgo()
|
||||
argo_file_path, err := new_wf.ExportToArgo(conf.GetConfig().Timeout)
|
||||
if err != nil {
|
||||
logger.Error().Msg("Could not create the Argo file for " + conf.GetConfig().WorkflowID)
|
||||
logger.Error().Msg(err.Error())
|
||||
@@ -202,23 +204,31 @@ func loadConfig(is_k8s bool, parser *argparse.Parser) {
|
||||
func setConf(is_k8s bool, o *onion.Onion, parser *argparse.Parser) {
|
||||
if is_k8s {
|
||||
conf.GetConfig().LokiURL = o.GetStringDefault("lokiurl", "http://127.0.0.1:3100")
|
||||
i, err := strconv.Atoi(o.GetString("timeout"))
|
||||
if err == nil {
|
||||
conf.GetConfig().Timeout = i
|
||||
} else {
|
||||
logger.Error().Msg("Could not parse timeout, using default value")
|
||||
}
|
||||
conf.GetConfig().ExecutionID = o.GetString("workflow")
|
||||
mongo := o.GetStringDefault("mongourl", "mongodb://127.0.0.1:27017")
|
||||
db := o.GetStringDefault("database", "DC_myDC")
|
||||
oclib.SetConfig(mongo, db)
|
||||
tools.SetConfig(mongo, db, "")
|
||||
} else {
|
||||
url := parser.String("u", "url", &argparse.Options{Required: true, Default: "http://127.0.0.1:3100", Help: "Url to the Loki database logs will be sent to"})
|
||||
workflow := parser.String("w", "workflow", &argparse.Options{Required: true, Help: "Execution ID of the workflow to request from oc-catalog API"})
|
||||
mongo := parser.String("m", "mongo", &argparse.Options{Required: true, Default: "mongodb://127.0.0.1:27017", Help: "URL to reach the MongoDB"})
|
||||
db := parser.String("d", "database", &argparse.Options{Required: true, Default: "DC_myDC", Help: "Name of the database to query in MongoDB"})
|
||||
timeout := parser.Int("t", "timeout", &argparse.Options{Required: false, Default: -1, Help: "Timeout for the execution of the workflow"})
|
||||
err := parser.Parse(os.Args)
|
||||
if err != nil {
|
||||
fmt.Println(parser.Usage(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
conf.GetConfig().LokiURL = *url
|
||||
conf.GetConfig().Timeout = *timeout
|
||||
conf.GetConfig().ExecutionID = *workflow
|
||||
oclib.SetConfig(*mongo, *db)
|
||||
tools.SetConfig(*mongo, *db, "")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user