logs for pods are better formatted
This commit is contained in:
parent
c31184e2ec
commit
27fd603e36
7
main.go
7
main.go
@ -169,14 +169,14 @@ func executeOutside(argo_file_path string, stepMax int, workflow workflow_builde
|
|||||||
steps = append(steps, template.Name)
|
steps = append(steps, template.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdLogs := exec.Command("argo", "logs", "oc-monitor-"+workflowName, "-n", conf.GetConfig().ExecutionID, "--follow")
|
cmdLogs := exec.Command("argo", "logs", "oc-monitor-"+workflowName, "-n", conf.GetConfig().ExecutionID, "--follow","--no-color")
|
||||||
if stdoutLogs, err = cmdLogs.StdoutPipe(); err != nil {
|
if stdoutLogs, err = cmdLogs.StdoutPipe(); err != nil {
|
||||||
wf_logger.Error().Msg("Could not retrieve stdoutpipe for 'argo logs'" + err.Error())
|
wf_logger.Error().Msg("Could not retrieve stdoutpipe for 'argo logs'" + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
go models.LogLocalWorkflow(workflowName, stdoutSubmit, &wg)
|
go models.LogLocalWorkflow(workflowName, stdoutSubmit, &wg)
|
||||||
go models.LogPods(stdoutLogs, steps, &wg)
|
go models.LogPods(workflowName, stdoutLogs, steps, &wg)
|
||||||
|
|
||||||
fmt.Println("Starting argo submit")
|
fmt.Println("Starting argo submit")
|
||||||
if err := cmdSubmit.Start(); err != nil {
|
if err := cmdSubmit.Start(); err != nil {
|
||||||
@ -189,7 +189,8 @@ func executeOutside(argo_file_path string, stepMax int, workflow workflow_builde
|
|||||||
|
|
||||||
fmt.Println("Running argo logs")
|
fmt.Println("Running argo logs")
|
||||||
if err := cmdLogs.Run(); err != nil {
|
if err := cmdLogs.Run(); err != nil {
|
||||||
wf_logger.Error().Msg("Could not run 'argo logs oc-monitor-" + workflowName + " -n " + conf.GetConfig().ExecutionID + " --follow")
|
wf_logger.Error().Msg("Could not run '" + strings.Join(cmdLogs.Args, " ") + "'")
|
||||||
|
|
||||||
wf_logger.Fatal().Msg(err.Error() + bufio.NewScanner(stderrLogs).Text())
|
wf_logger.Fatal().Msg(err.Error() + bufio.NewScanner(stderrLogs).Text())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,3 +145,17 @@ func (a *ArgoLogs) StopStepRecording(current *ArgoWatch) *ArgoWatch {
|
|||||||
current.Status = status
|
current.Status = status
|
||||||
return current
|
return current
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ArgoPodLog struct {
|
||||||
|
PodName string
|
||||||
|
Step string
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArgoPodLog(name string, step string, msg string) ArgoPodLog {
|
||||||
|
return ArgoPodLog{
|
||||||
|
PodName: name,
|
||||||
|
Step: step,
|
||||||
|
Message: msg,
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@ var wfLogger zerolog.Logger
|
|||||||
|
|
||||||
|
|
||||||
// Take the slice of string that make up one round of stderr outputs from the --watch option in argo submit
|
// Take the slice of string that make up one round of stderr outputs from the --watch option in argo submit
|
||||||
func NewLocalArgoLogs(inputs []string) *ArgoWatch {
|
func NewLocalArgoWatch(inputs []string) *ArgoWatch {
|
||||||
var workflow ArgoWatch
|
var workflow ArgoWatch
|
||||||
|
|
||||||
for _, input := range inputs {
|
for _, input := range inputs {
|
||||||
@ -84,7 +84,7 @@ func LogLocalWorkflow(wfName string, pipe io.ReadCloser, wg *sync.WaitGroup) {
|
|||||||
// Log the progress of the WF
|
// Log the progress of the WF
|
||||||
if strings.HasPrefix(log, "Progress:") {
|
if strings.HasPrefix(log, "Progress:") {
|
||||||
|
|
||||||
current_watch = *NewLocalArgoLogs(watch_output)
|
current_watch = *NewLocalArgoWatch(watch_output)
|
||||||
workflowName := current_watch.Name
|
workflowName := current_watch.Name
|
||||||
if !current_watch.Equals(&previous_watch) {
|
if !current_watch.Equals(&previous_watch) {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -106,17 +106,24 @@ func LogLocalWorkflow(wfName string, pipe io.ReadCloser, wg *sync.WaitGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Debug, no logs sent
|
// Debug, no logs sent
|
||||||
func LogPods(pipe io.ReadCloser, steps []string, wg *sync.WaitGroup) {
|
func LogPods(wfName string, pipe io.ReadCloser, steps []string, wg *sync.WaitGroup) {
|
||||||
scanner := bufio.NewScanner(pipe)
|
scanner := bufio.NewScanner(pipe)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
var podLogger zerolog.Logger
|
||||||
fmt.Println("new line")
|
fmt.Println("new line")
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
var podLogger zerolog.Logger
|
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
podName := strings.Split(line, ":")[0]
|
podName := strings.Split(line, ":")[0]
|
||||||
podLogger = wfLogger.With().Str("step_name", getStepName(podName, steps)).Logger()
|
podLogger = wfLogger.With().Str("step_name", getStepName(podName, steps)).Logger()
|
||||||
log := strings.Split(line,podName+":")[1]
|
log := strings.Split(line,podName+":")[1]
|
||||||
podLogger.Info().Msg(log)
|
podLog := NewArgoPodLog(wfName,podName,log)
|
||||||
|
jsonifiedLog, err := json.Marshal(podLog)
|
||||||
|
if err != nil {
|
||||||
|
podLogger.Fatal().Msg(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
podLogger.Info().Msg(string(jsonifiedLog))
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user