Skip to content

fix(spark): populate timestamp fields in log template input#7271

Open
cmditch wants to merge 1 commit intoflyteorg:masterfrom
cmditch:fix/spark-log-timestamps
Open

fix(spark): populate timestamp fields in log template input#7271
cmditch wants to merge 1 commit intoflyteorg:masterfrom
cmditch:fix/spark-log-timestamps

Conversation

@cmditch
Copy link
Copy Markdown

@cmditch cmditch commented Apr 24, 2026

Summary

The Spark plugin's getEventInfoForSpark constructs tasklog.Input without populating any timestamp fields (PodUnixStartTime, PodUnixFinishTime, PodRFC3339StartTime, PodRFC3339FinishTime). This causes log template URIs referencing {{ .podUnixStartTime }} to render as 0, making it impossible to construct time-bounded log links for external logging services like Grafana Loki or Kibana.

The standard K8s plugin (logging_utils.go) and kfoperators (common_operator.go) already populate these fields from the resource's CreationTimestamp. This change applies the same pattern to all four tasklog.Input structs in getEventInfoForSpark.

Changes

  • Compute startTime from sj.CreationTimestamp.Unix() and finishTime from time.Now().Unix() at the top of getEventInfoForSpark
  • Populate PodUnixStartTime, PodUnixFinishTime, PodRFC3339StartTime, and PodRFC3339FinishTime in all four tasklog.Input structs (Driver, User, System, and All-User logs)
  • Added TestGetEventInfoTimestamps test that verifies timestamp template variables are correctly populated in generated log URIs

Testing

  • All existing Spark plugin tests pass
  • New test verifies that a log template URI containing {{ .podUnixStartTime }} renders the actual creation timestamp rather than 0
  • Manually tested against a Flyte Binary deployment with Grafana Loki log links using {{ .podUnixStartTime }}000 for epoch-ms time ranges

Fixes #6328

@cmditch cmditch force-pushed the fix/spark-log-timestamps branch from 6021c65 to 02f75fb Compare April 24, 2026 05:11
The Spark plugin constructs tasklog.Input without setting any of the
timestamp fields (PodUnixStartTime, PodUnixFinishTime, and their
RFC3339 equivalents). This causes log template URIs that reference
{{ .podUnixStartTime }} to render as 0, making it impossible to
construct time-bounded log links for external logging services like
Grafana Loki or Kibana.

The standard K8s plugin and kfoperators already populate these fields
from the resource's CreationTimestamp. This change does the same for
all four tasklog.Input structs in getEventInfoForSpark.

Fixes flyteorg#6328

Signed-off-by: Coury Ditch <cmditch@gmail.com>
@cmditch cmditch force-pushed the fix/spark-log-timestamps branch from 02f75fb to ff2a24a Compare April 24, 2026 05:20
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.97%. Comparing base (682d81e) to head (ff2a24a).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7271      +/-   ##
==========================================
+ Coverage   56.95%   56.97%   +0.01%     
==========================================
  Files         931      931              
  Lines       58250    58268      +18     
==========================================
+ Hits        33179    33197      +18     
  Misses      22017    22017              
  Partials     3054     3054              
Flag Coverage Δ
unittests-datacatalog 53.51% <ø> (ø)
unittests-flyteadmin 53.14% <ø> (ø)
unittests-flytecopilot 43.06% <ø> (ø)
unittests-flytectl 64.09% <ø> (ø)
unittests-flyteidl 75.71% <ø> (ø)
unittests-flyteplugins 60.26% <100.00%> (+0.06%) ⬆️
unittests-flytepropeller 53.71% <ø> (ø)
unittests-flytestdlib 62.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

taskExecID := pluginContext.TaskExecutionMetadata().GetTaskExecutionID()

startTime := sj.CreationTimestamp.Unix()
finishTime := time.Now().Unix()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does spark job crd have finish time? Also, we should only set it when job is completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core feature] Add some start time template variable for Spark log links

2 participants