-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Allow controlling in which task phases log links are shown #4726
Changes from all commits
0ba3b4a
02d1067
666b209
9324f10
52c1a61
de4de1a
ab93bc5
703548a
1873c3d
8122e76
2c742a5
039d922
c73e59f
0bb5fc2
79d51f5
0c8bdc3
d4102ac
66db326
720f053
24c8a80
382ed0a
105b766
383c043
0aa3d81
459c70d
e494723
5dc8525
edf30fc
2e54f69
dfc44b4
f8c68c5
7bfc8bc
683a6a5
f557e37
3bfba55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -372,6 +372,31 @@ func mergeMetadata(existing, latest *event.TaskExecutionMetadata) *event.TaskExe | |
return existing | ||
} | ||
|
||
func filterExternalResourceLogsByPhase(externalResources []*event.ExternalResourceInfo, phase core.TaskExecution_Phase) { | ||
for _, externalResource := range externalResources { | ||
externalResource.Logs = filterLogsByPhase(externalResource.Logs, phase) | ||
} | ||
} | ||
|
||
func filterLogsByPhase(logs []*core.TaskLog, phase core.TaskExecution_Phase) []*core.TaskLog { | ||
filteredLogs := make([]*core.TaskLog, 0, len(logs)) | ||
|
||
for _, l := range logs { | ||
if common.IsTaskExecutionTerminal(phase) && l.HideOnceFinished { | ||
continue | ||
} | ||
// Some plugins like e.g. Dask, Ray start with or very quickly transition to core.TaskExecution_INITIALIZING | ||
// once the CR has been created even though the underlying pods are still pending. We thus treat queued and | ||
// initializing the same here. | ||
if (phase == core.TaskExecution_QUEUED || phase == core.TaskExecution_INITIALIZING) && !l.ShowWhilePending { | ||
continue | ||
} | ||
filteredLogs = append(filteredLogs, l) | ||
|
||
} | ||
return filteredLogs | ||
} | ||
|
||
func UpdateTaskExecutionModel(ctx context.Context, request *admin.TaskExecutionEventRequest, taskExecutionModel *models.TaskExecution, | ||
inlineEventDataPolicy interfaces.InlineEventDataPolicy, storageClient *storage.DataStore) error { | ||
err := handleTaskExecutionInputs(ctx, taskExecutionModel, request, storageClient) | ||
|
@@ -384,6 +409,7 @@ func UpdateTaskExecutionModel(ctx context.Context, request *admin.TaskExecutionE | |
return errors.NewFlyteAdminErrorf(codes.Internal, | ||
"failed to unmarshal task execution closure with error: %+v", err) | ||
} | ||
isPhaseChange := taskExecutionModel.Phase != request.Event.Phase.String() | ||
existingTaskPhase := taskExecutionModel.Phase | ||
taskExecutionModel.Phase = request.Event.Phase.String() | ||
taskExecutionModel.PhaseVersion = request.Event.PhaseVersion | ||
|
@@ -393,7 +419,11 @@ func UpdateTaskExecutionModel(ctx context.Context, request *admin.TaskExecutionE | |
reportedAt = request.Event.OccurredAt | ||
} | ||
taskExecutionClosure.UpdatedAt = reportedAt | ||
taskExecutionClosure.Logs = mergeLogs(taskExecutionClosure.Logs, request.Event.Logs) | ||
|
||
mergedLogs := mergeLogs(taskExecutionClosure.Logs, request.Event.Logs) | ||
filteredLogs := filterLogsByPhase(mergedLogs, request.Event.Phase) | ||
taskExecutionClosure.Logs = filteredLogs | ||
|
||
if len(request.Event.Reasons) > 0 { | ||
for _, reason := range request.Event.Reasons { | ||
taskExecutionClosure.Reasons = append( | ||
|
@@ -437,6 +467,11 @@ func UpdateTaskExecutionModel(ctx context.Context, request *admin.TaskExecutionE | |
return errors.NewFlyteAdminErrorf(codes.Internal, "failed to merge task event custom_info with error: %v", err) | ||
} | ||
taskExecutionClosure.Metadata = mergeMetadata(taskExecutionClosure.Metadata, request.Event.Metadata) | ||
|
||
if isPhaseChange && taskExecutionClosure.Metadata != nil && len(taskExecutionClosure.Metadata.ExternalResources) > 0 { | ||
filterExternalResourceLogsByPhase(taskExecutionClosure.Metadata.ExternalResources, request.Event.Phase) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required for map tasks which treat log links differently for performance/scalability reasons. Master: This branch: Note that the task execution view with the log links only becomes available in the running phase for map tasks, meaning that there is no use case for showing log links already in the pending phase. However, log links can be removed once finished. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: array node map tasks replaced map tasks in flytekit 1.12.0 and this distinction is no longer true, i.e. array node map tasks log links no longer use the separate map tasks log links. |
||
if request.Event.EventVersion > taskExecutionClosure.EventVersion { | ||
taskExecutionClosure.EventVersion = request.Event.EventVersion | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a high level, the contract between flyteplugins/flytepropeller and flyteadmin changes the following way:
Before:
Running
phase, only exception being the spark plugin), the plugin needs to send this log link in that phase.After:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did briefly consider whether a plugin should be able to send a log link which will e.g. be shown only from
Running
onwards only a single time already in a prior phase, e.g.Pending
. This would mean that flyteadmin would have to track the still inactive log link and then make it active once the running phase is reached.I personally think this is an overkill though since currently all plugins always send all links. I feel the contract "If you want a log link to be shown from a specific phase onwards, you need to send the log link at least in this phase" is reasonable.