Skip to content

Commit

Permalink
Store task execution event reason & task type (flyteorg#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
Katrina Rogan authored Jun 25, 2021
1 parent 6a1d9bc commit 947d61f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions flyteadmin/pkg/repositories/transformers/task_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func CreateTaskExecutionModel(input CreateTaskExecutionModelInput) (*models.Task
CreatedAt: input.Request.Event.OccurredAt,
Logs: input.Request.Event.Logs,
CustomInfo: input.Request.Event.CustomInfo,
Reason: input.Request.Event.Reason,
TaskType: input.Request.Event.TaskType,
}

eventPhase := input.Request.Event.Phase
Expand Down Expand Up @@ -209,6 +211,9 @@ func UpdateTaskExecutionModel(request *admin.TaskExecutionEventRequest, taskExec
taskExecutionClosure.Phase = request.Event.Phase
taskExecutionClosure.UpdatedAt = request.Event.OccurredAt
taskExecutionClosure.Logs = mergeLogs(taskExecutionClosure.Logs, request.Event.Logs)
if len(request.Event.Reason) > 0 {
taskExecutionClosure.Reason = request.Event.Reason
}
if (existingTaskPhase == core.TaskExecution_QUEUED.String() || existingTaskPhase == core.TaskExecution_UNDEFINED.String()) && taskExecutionModel.Phase == core.TaskExecution_RUNNING.String() {
err = addTaskStartedState(request, taskExecutionModel, &taskExecutionClosure)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func TestCreateTaskExecutionModelQueued(t *testing.T) {
RetryAttempt: 1,
InputUri: "input uri",
OccurredAt: taskEventOccurredAtProto,
Reason: "Task was scheduled",
TaskType: "sidecar",
},
},
})
Expand All @@ -161,6 +163,8 @@ func TestCreateTaskExecutionModelQueued(t *testing.T) {
StartedAt: nil,
CreatedAt: taskEventOccurredAtProto,
UpdatedAt: taskEventOccurredAtProto,
Reason: "Task was scheduled",
TaskType: "sidecar",
}

expectedClosureBytes, err := proto.Marshal(expectedClosure)
Expand Down Expand Up @@ -350,6 +354,7 @@ func TestUpdateTaskExecutionModelRunningToFailed(t *testing.T) {
CustomInfo: transformMapToStructPB(t, map[string]string{
"key1": "value1 updated",
}),
Reason: "task failed",
},
}

Expand Down Expand Up @@ -379,6 +384,7 @@ func TestUpdateTaskExecutionModelRunningToFailed(t *testing.T) {
CustomInfo: transformMapToStructPB(t, map[string]string{
"key1": "value1 updated",
}),
Reason: "task failed",
}

expectedClosureBytes, err := proto.Marshal(expectedClosure)
Expand Down

0 comments on commit 947d61f

Please sign in to comment.