From 23e0c18610e382b8237b45e917ce7e619d27ec8c Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:33:17 +1100 Subject: [PATCH 1/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- util/logs/workflow-logger.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/logs/workflow-logger.go b/util/logs/workflow-logger.go index d33698416cf1..f98df8f15118 100644 --- a/util/logs/workflow-logger.go +++ b/util/logs/workflow-logger.go @@ -109,6 +109,10 @@ func WorkflowLogs(ctx context.Context, wfClient versioned.Interface, kubeClient logOptions = &corev1.PodLogOptions{} } logCtx.WithField("options", logOptions).Debug("Log options") + // todo this should really check if the container name exists in the pod + if logOptions.Container == "" { + return fmt.Errorf("container name must be specified") + } // make a copy of requested log options and set timestamps to true, so they can be parsed out later podLogStreamOptions := *logOptions From 524d954047c7d2a1bedb3b2ac101e469f363f898 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:35:29 +1100 Subject: [PATCH 2/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- util/logs/pods-logger.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/logs/pods-logger.go b/util/logs/pods-logger.go index a7b5b2e12e98..5af03c9d2b21 100644 --- a/util/logs/pods-logger.go +++ b/util/logs/pods-logger.go @@ -21,6 +21,10 @@ func LogPods(ctx context.Context, kubernetesClient kubernetes.Interface, namespa if podLogOptions == nil { podLogOptions = &corev1.PodLogOptions{} } + // todo this should really check if the container name exists in the pod + if podLogOptions.Container == "" { + return fmt.Errorf("container name must be specified") + } rx, err := regexp.Compile(grep) if err != nil { return err From 0d3dc5d815bdb93a953ff654c6262b7c82c407ec Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:46:02 +1100 Subject: [PATCH 3/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- util/logs/pods-logger.go | 1 + 1 file changed, 1 insertion(+) diff --git a/util/logs/pods-logger.go b/util/logs/pods-logger.go index 5af03c9d2b21..1458c12cdabe 100644 --- a/util/logs/pods-logger.go +++ b/util/logs/pods-logger.go @@ -3,6 +3,7 @@ package logs import ( "bufio" "context" + "fmt" "io" "regexp" "sync" From 3e46e36032ce520fb64440db39dc68849ee63ad9 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Wed, 6 Nov 2024 06:02:02 +1100 Subject: [PATCH 4/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- server/workflow/workflow_server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/workflow/workflow_server_test.go b/server/workflow/workflow_server_test.go index 366ed020b5d1..555297531450 100644 --- a/server/workflow/workflow_server_test.go +++ b/server/workflow/workflow_server_test.go @@ -910,7 +910,7 @@ func TestPodLogs(t *testing.T) { err := server.PodLogs(&workflowpkg.WorkflowLogRequest{ Name: "hello-world-9tql2", Namespace: "workflows", - LogOptions: &corev1.PodLogOptions{}, + LogOptions: &corev1.PodLogOptions{Container: "main"}, }, &testPodLogsServer{testServerStream{ctx}}) assert.NoError(t, err) }() From c491affc2f928966823a623e6af5749603239523 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Wed, 6 Nov 2024 06:08:12 +1100 Subject: [PATCH 5/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- util/logs/pods-logger.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/util/logs/pods-logger.go b/util/logs/pods-logger.go index 1458c12cdabe..a7b5b2e12e98 100644 --- a/util/logs/pods-logger.go +++ b/util/logs/pods-logger.go @@ -3,7 +3,6 @@ package logs import ( "bufio" "context" - "fmt" "io" "regexp" "sync" @@ -22,10 +21,6 @@ func LogPods(ctx context.Context, kubernetesClient kubernetes.Interface, namespa if podLogOptions == nil { podLogOptions = &corev1.PodLogOptions{} } - // todo this should really check if the container name exists in the pod - if podLogOptions.Container == "" { - return fmt.Errorf("container name must be specified") - } rx, err := regexp.Compile(grep) if err != nil { return err From 21616218f1b10e633ae38b5a2a37572f6ede2c87 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Wed, 6 Nov 2024 06:08:40 +1100 Subject: [PATCH 6/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- server/workflow/workflow_server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/workflow/workflow_server_test.go b/server/workflow/workflow_server_test.go index 555297531450..366ed020b5d1 100644 --- a/server/workflow/workflow_server_test.go +++ b/server/workflow/workflow_server_test.go @@ -910,7 +910,7 @@ func TestPodLogs(t *testing.T) { err := server.PodLogs(&workflowpkg.WorkflowLogRequest{ Name: "hello-world-9tql2", Namespace: "workflows", - LogOptions: &corev1.PodLogOptions{Container: "main"}, + LogOptions: &corev1.PodLogOptions{}, }, &testPodLogsServer{testServerStream{ctx}}) assert.NoError(t, err) }() From 522f29d29bd851d92fc741ec9e2c71052e2dd86f Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Wed, 6 Nov 2024 07:42:42 +1100 Subject: [PATCH 7/7] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- server/workflow/workflow_server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/workflow/workflow_server_test.go b/server/workflow/workflow_server_test.go index 366ed020b5d1..555297531450 100644 --- a/server/workflow/workflow_server_test.go +++ b/server/workflow/workflow_server_test.go @@ -910,7 +910,7 @@ func TestPodLogs(t *testing.T) { err := server.PodLogs(&workflowpkg.WorkflowLogRequest{ Name: "hello-world-9tql2", Namespace: "workflows", - LogOptions: &corev1.PodLogOptions{}, + LogOptions: &corev1.PodLogOptions{Container: "main"}, }, &testPodLogsServer{testServerStream{ctx}}) assert.NoError(t, err) }()