Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Tracking reasons time-series #540

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,5 @@ require (
)

replace github.com/robfig/cron/v3 => github.com/unionai/cron/v3 v3.0.2-0.20210825070134-bfc34418fe84

replace github.com/flyteorg/flyteidl => github.com/flyteorg/flyteidl v1.3.13-0.20230314170834-f9ca57c4d71b
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/flyteorg/flyteidl v1.3.9 h1:MHUa89yKwCz58mQC2OxTzYjr0d3fA14qKG462v+RAyk=
github.com/flyteorg/flyteidl v1.3.9/go.mod h1:Pkt2skI1LiHs/2ZoekBnyPhuGOFMiuul6HHcKGZBsbM=
github.com/flyteorg/flyteidl v1.3.13-0.20230314170834-f9ca57c4d71b h1:yj9MgNGhIlzjKJ4hgsh1J0+cK+3Gmszoy39Z6l2V62w=
github.com/flyteorg/flyteidl v1.3.13-0.20230314170834-f9ca57c4d71b/go.mod h1:Pkt2skI1LiHs/2ZoekBnyPhuGOFMiuul6HHcKGZBsbM=
github.com/flyteorg/flyteplugins v1.0.20 h1:8ZGN2c0iaZa3d/UmN2VYozLBRhthAIO48aD5g8Wly7s=
github.com/flyteorg/flyteplugins v1.0.20/go.mod h1:ZbZVBxEWh8Icj1AgfNKg0uPzHHGd9twa4eWcY2Yt6xE=
github.com/flyteorg/flytepropeller v1.1.51 h1:ITPH2Fqx+/1hKBFnfb6Rawws3VbEJ3tQ/1tQXSIXvcQ=
Expand Down
18 changes: 18 additions & 0 deletions pkg/repositories/transformers/task_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ func CreateTaskExecutionModel(ctx context.Context, input CreateTaskExecutionMode
EventVersion: input.Request.Event.EventVersion,
}

if len(input.Request.Event.Reason) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this right? should it not check for len(closure.Reasons) <= 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so this is run in CreateTaskExecutionModel so closure.Reasons will always be 0 because we just created the closure. This just says - don't add a reason to the time-series if the reason is an empty string.

closure.Reasons = []*admin.Reason{
&admin.Reason{
OccurredAt: input.Request.Event.OccurredAt,
Message: input.Request.Event.Reason,
},
}
}

eventPhase := input.Request.Event.Phase

// Different tasks may report different phases as their first event.
Expand Down Expand Up @@ -362,6 +371,15 @@ func UpdateTaskExecutionModel(ctx context.Context, request *admin.TaskExecutionE
taskExecutionClosure.UpdatedAt = request.Event.OccurredAt
taskExecutionClosure.Logs = mergeLogs(taskExecutionClosure.Logs, request.Event.Logs)
if len(request.Event.Reason) > 0 {
if taskExecutionClosure.Reason != request.Event.Reason {
hamersaw marked this conversation as resolved.
Show resolved Hide resolved
taskExecutionClosure.Reasons = append(
taskExecutionClosure.Reasons,
&admin.Reason{
OccurredAt: request.Event.OccurredAt,
Message: request.Event.Reason,
})
}

taskExecutionClosure.Reason = request.Event.Reason
}
if existingTaskPhase != core.TaskExecution_RUNNING.String() && taskExecutionModel.Phase == core.TaskExecution_RUNNING.String() {
Expand Down
27 changes: 26 additions & 1 deletion pkg/repositories/transformers/task_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,13 @@ func TestCreateTaskExecutionModelQueued(t *testing.T) {
CreatedAt: taskEventOccurredAtProto,
UpdatedAt: taskEventOccurredAtProto,
Reason: "Task was scheduled",
TaskType: "sidecar",
Reasons: []*admin.Reason{
&admin.Reason{
OccurredAt: taskEventOccurredAtProto,
Message: "Task was scheduled",
},
},
TaskType: "sidecar",
}

expectedClosureBytes, err := proto.Marshal(expectedClosure)
Expand Down Expand Up @@ -338,6 +344,8 @@ func TestCreateTaskExecutionModelRunning(t *testing.T) {
CustomInfo: &customInfo,
}

t.Logf("expected %+v %+v\n", expectedClosure.Reason, expectedClosure.Reasons)

expectedClosureBytes, err := proto.Marshal(expectedClosure)
assert.Nil(t, err)

Expand Down Expand Up @@ -386,6 +394,13 @@ func TestUpdateTaskExecutionModelRunningToFailed(t *testing.T) {
CustomInfo: transformMapToStructPB(t, map[string]string{
"key1": "value1",
}),
Reason: "Task was scheduled",
Reasons: []*admin.Reason{
&admin.Reason{
OccurredAt: taskEventOccurredAtProto,
Message: "Task was scheduled",
},
},
}

closureBytes, err := proto.Marshal(existingClosure)
Expand Down Expand Up @@ -481,6 +496,16 @@ func TestUpdateTaskExecutionModelRunningToFailed(t *testing.T) {
"key1": "value1 updated",
}),
Reason: "task failed",
Reasons: []*admin.Reason{
&admin.Reason{
OccurredAt: taskEventOccurredAtProto,
Message: "Task was scheduled",
},
&admin.Reason{
OccurredAt: occuredAtProto,
Message: "task failed",
},
},
}

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