From d1a723e001556e1fb301e2d7e61735dda0b41558 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Thu, 14 Nov 2024 18:03:31 -0800 Subject: [PATCH] Add visibility control to dynamic log links (#6000) * Add visibility control to dynamic log links Signed-off-by: Kevin Su * Add visibility control to dynamic log links Signed-off-by: Kevin Su * update logging utils Signed-off-by: Kevin Su --------- Signed-off-by: Kevin Su --- flyteplugins/go/tasks/logs/logging_utils.go | 2 ++ .../tasks/pluginmachinery/tasklog/template.go | 8 +++-- .../pluginmachinery/tasklog/template_test.go | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/flyteplugins/go/tasks/logs/logging_utils.go b/flyteplugins/go/tasks/logs/logging_utils.go index 1b442fd766..c237fc15c8 100644 --- a/flyteplugins/go/tasks/logs/logging_utils.go +++ b/flyteplugins/go/tasks/logs/logging_utils.go @@ -131,6 +131,8 @@ func InitializeLogPlugins(cfg *LogConfig) (tasklog.Plugin, error) { DisplayName: dynamicLogLink.DisplayName, DynamicTemplateURIs: dynamicLogLink.TemplateURIs, MessageFormat: core.TaskLog_JSON, + ShowWhilePending: dynamicLogLink.ShowWhilePending, + HideOnceFinished: dynamicLogLink.HideOnceFinished, }) } diff --git a/flyteplugins/go/tasks/pluginmachinery/tasklog/template.go b/flyteplugins/go/tasks/pluginmachinery/tasklog/template.go index 6080754036..e8b7a4abed 100644 --- a/flyteplugins/go/tasks/pluginmachinery/tasklog/template.go +++ b/flyteplugins/go/tasks/pluginmachinery/tasklog/template.go @@ -219,9 +219,11 @@ func (p TemplateLogPlugin) GetTaskLogs(input Input) (Output, error) { } } taskLogs = append(taskLogs, &core.TaskLog{ - Uri: replaceAll(dynamicTemplateURI, templateVars), - Name: p.DisplayName + input.LogName, - MessageFormat: p.MessageFormat, + Uri: replaceAll(dynamicTemplateURI, templateVars), + Name: p.DisplayName + input.LogName, + MessageFormat: p.MessageFormat, + ShowWhilePending: p.ShowWhilePending, + HideOnceFinished: p.HideOnceFinished, }) } } diff --git a/flyteplugins/go/tasks/pluginmachinery/tasklog/template_test.go b/flyteplugins/go/tasks/pluginmachinery/tasklog/template_test.go index 42226bd7c0..2e885732f8 100644 --- a/flyteplugins/go/tasks/pluginmachinery/tasklog/template_test.go +++ b/flyteplugins/go/tasks/pluginmachinery/tasklog/template_test.go @@ -478,6 +478,37 @@ func TestTemplateLogPlugin(t *testing.T) { }, }, }, + { + "flyteinteractive", + TemplateLogPlugin{ + Name: "vscode", + DynamicTemplateURIs: []TemplateURI{"vscode://flyteinteractive:{{ .taskConfig.port }}/{{ .podName }}"}, + MessageFormat: core.TaskLog_JSON, + HideOnceFinished: true, + ShowWhilePending: true, + }, + args{ + input: Input{ + PodName: "my-pod-name", + TaskTemplate: &core.TaskTemplate{ + Config: map[string]string{ + "link_type": "vscode", + "port": "1234", + }, + }, + }, + }, + Output{ + TaskLogs: []*core.TaskLog{ + { + Uri: "vscode://flyteinteractive:1234/my-pod-name", + MessageFormat: core.TaskLog_JSON, + ShowWhilePending: true, + HideOnceFinished: true, + }, + }, + }, + }, { "flyteinteractive - no link_type in task template", TemplateLogPlugin{