pod logging

This commit is contained in:
rushtehrani
2020-01-09 15:08:25 -08:00
parent 32442b5b04
commit d124e587c1
8 changed files with 461 additions and 47 deletions

View File

@@ -1,6 +1,7 @@
package manager
import (
"bufio"
"encoding/json"
"fmt"
"os"
@@ -134,6 +135,23 @@ func (r *ResourceManager) WatchWorkflow(namespace, name string) (<-chan *model.W
return workflowWatcher, nil
}
func (r *ResourceManager) GetWorkflowLogs(namespace, name, podName, containerName string) (<-chan *model.LogEntry, error) {
stream, err := r.kubeClient.GetPodLogs(namespace, podName, containerName)
logWatcher := make(chan *model.LogEntry)
if err != nil {
go func() {
scanner := bufio.NewScanner(stream)
for scanner.Scan() {
logWatcher <- &model.LogEntry{Content: scanner.Text()}
}
close(logWatcher)
}()
}
return logWatcher, nil
}
func (r *ResourceManager) ListWorkflows(namespace, workflowTemplateUID string) (workflows []*model.Workflow, err error) {
opts := &kube.WorkflowOptions{}
if workflowTemplateUID != "" {