Skip to content

Commit

Permalink
move pod start/end time to a common template vars (#4676)
Browse files Browse the repository at this point in the history
pod start/end time is useful to have even with TemplateSchemeTaskExecution,
to construct precise timerange in the URL.

Signed-off-by: vraiyani <[email protected]>
Co-authored-by: David Espejo <[email protected]>
Co-authored-by: Kevin Su <[email protected]>
  • Loading branch information
3 people authored and katrogan committed Jan 12, 2024
1 parent 447c53f commit 4de8fa3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
24 changes: 14 additions & 10 deletions flyteplugins/go/tasks/pluginmachinery/tasklog/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@ func (input Input) templateVarsForScheme(scheme TemplateScheme) TemplateVars {
TemplateVar{defaultRegexes.ContainerName, input.ContainerName},
TemplateVar{defaultRegexes.ContainerID, containerID},
TemplateVar{defaultRegexes.Hostname, input.HostName},
TemplateVar{defaultRegexes.PodRFC3339StartTime, input.PodRFC3339StartTime},
TemplateVar{defaultRegexes.PodRFC3339FinishTime, input.PodRFC3339FinishTime},
TemplateVar{
defaultRegexes.PodUnixStartTime,
strconv.FormatInt(input.PodUnixStartTime, 10),
},
TemplateVar{
defaultRegexes.PodUnixFinishTime,
strconv.FormatInt(input.PodUnixFinishTime, 10),
},
)
if gotExtraTemplateVars {
vars = append(vars, input.ExtraTemplateVarsByScheme.Pod...)
Expand Down Expand Up @@ -187,6 +177,20 @@ func (input Input) templateVarsForScheme(scheme TemplateScheme) TemplateVars {
}
}

vars = append(
vars,
TemplateVar{defaultRegexes.PodRFC3339StartTime, input.PodRFC3339StartTime},
TemplateVar{defaultRegexes.PodRFC3339FinishTime, input.PodRFC3339FinishTime},
TemplateVar{
defaultRegexes.PodUnixStartTime,
strconv.FormatInt(input.PodUnixStartTime, 10),
},
TemplateVar{
defaultRegexes.PodUnixFinishTime,
strconv.FormatInt(input.PodUnixFinishTime, 10),
},
)

return vars
}

Expand Down
12 changes: 10 additions & 2 deletions flyteplugins/go/tasks/pluginmachinery/tasklog/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ func Test_Input_templateVarsForScheme(t *testing.T) {
PodUnixFinishTime: 12345,
}
taskExecutionBase := Input{
LogName: "main_logs",
TaskExecutionID: dummyTaskExecID(),
LogName: "main_logs",
TaskExecutionID: dummyTaskExecID(),
PodRFC3339StartTime: "1970-01-01T01:02:03+01:00",
PodRFC3339FinishTime: "1970-01-01T04:25:45+01:00",
PodUnixStartTime: 123,
PodUnixFinishTime: 12345,
}
flyinBase := Input{
HostName: "my-host",
Expand Down Expand Up @@ -178,6 +182,10 @@ func Test_Input_templateVarsForScheme(t *testing.T) {
{defaultRegexes.ExecutionName, "my-execution-name"},
{defaultRegexes.ExecutionProject, "my-execution-project"},
{defaultRegexes.ExecutionDomain, "my-execution-domain"},
{defaultRegexes.PodRFC3339StartTime, "1970-01-01T01:02:03+01:00"},
{defaultRegexes.PodRFC3339FinishTime, "1970-01-01T04:25:45+01:00"},
{defaultRegexes.PodUnixStartTime, "123"},
{defaultRegexes.PodUnixFinishTime, "12345"},
},
nil,
nil,
Expand Down

0 comments on commit 4de8fa3

Please sign in to comment.