Skip to content

Commit

Permalink
Hide certain logs once finished
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Graetz <[email protected]>
  • Loading branch information
fg91 committed Mar 8, 2024
1 parent 59cc908 commit 66c6b29
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions flyteplugins/go/tasks/pluginmachinery/core/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func PhaseInfoInitializing(t time.Time, version uint32, reason string, info *Tas
}

func phaseInfoFailed(p Phase, err *core.ExecutionError, info *TaskInfo, cleanupOnFailure bool) PhaseInfo {
HideLogsOnceFinished(info)
if err == nil {
err = &core.ExecutionError{
Code: "Unknown",
Expand All @@ -266,7 +267,30 @@ func PhaseInfoRunning(version uint32, info *TaskInfo) PhaseInfo {
return phaseInfo(PhaseRunning, version, nil, info, false)
}

func HideLogsOnceFinished(info *TaskInfo) {
if info != nil && info.Logs != nil {
logs := info.Logs
// Delete the logs for which hideOnceFinished is true
info.Logs = make([]*core.TaskLog, 0, len(logs))
for _, l := range logs {
if !l.HideOnceFinished {
info.Logs = append(info.Logs, l)
}
}
}
}

func PhaseInfoSuccess(info *TaskInfo) PhaseInfo {
if info != nil && info.Logs != nil {
logs := info.Logs
// Delete the logs for which hideOnceFinished is true
info.Logs = make([]*core.TaskLog, 0, len(logs))
for _, l := range logs {
if !l.HideOnceFinished {
info.Logs = append(info.Logs, l)
}
}
}
return phaseInfo(PhaseSuccess, DefaultPhaseVersion, nil, info, false)
}

Expand Down
1 change: 1 addition & 0 deletions flyteplugins/go/tasks/pluginmachinery/tasklog/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ type TemplateLogPlugin struct {
// Deprecated: Please, do not use
DeprecatedScheme TemplateScheme `json:"scheme" pflag:",Templating scheme to use. Supported values are Pod and TaskExecution."`
ShowWhilePending bool `json:"showWhilePending" pflag:",If true, the log link will be shown even if the task is in a pending state."`
HideOnceFinished bool `json:"hideOnceFinished" pflag:",If true, the log link will be hidden once the task has finished."`
}
1 change: 1 addition & 0 deletions flyteplugins/go/tasks/pluginmachinery/tasklog/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ func (p TemplateLogPlugin) GetTaskLogs(input Input) (Output, error) {
Name: p.DisplayName + input.LogName,
MessageFormat: p.MessageFormat,
ShowWhilePending: p.ShowWhilePending,
HideOnceFinished: p.HideOnceFinished,
})
}

Expand Down

0 comments on commit 66c6b29

Please sign in to comment.