Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions flyteadmin/pkg/repositories/transformers/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ func CreateExecutionModel(input CreateExecutionModelInput) (*models.Execution, e

activeExecution := int32(admin.ExecutionState_EXECUTION_ACTIVE)

// Populate the top-level ErrorKind/ErrorCode columns at create time so executions that
// fail before the propeller event path (e.g. accept-time validation failures) are
// queryable without deserializing the closure (mirrors UpdateExecutionModelState).
var errorKind, errorCode *string
if execErr := closure.GetError(); execErr != nil {
kind := execErr.GetKind().String()
code := execErr.GetCode()
errorKind = &kind
errorCode = &code
}

executionModel := &models.Execution{
ExecutionKey: models.ExecutionKey{
Project: input.WorkflowExecutionID.GetProject(),
Expand All @@ -132,6 +143,8 @@ func CreateExecutionModel(input CreateExecutionModelInput) (*models.Execution, e
User: requestSpec.GetMetadata().GetPrincipal(),
State: &activeExecution,
LaunchEntity: strings.ToLower(input.LaunchEntity.String()),
ErrorKind: errorKind,
ErrorCode: errorCode,
}
// A reference launch entity can be one of either or a task OR launch plan. Traditionally, workflows are executed
// with a reference launch plan which is why this behavior is the default below.
Expand Down
14 changes: 14 additions & 0 deletions flyteadmin/pkg/repositories/transformers/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func TestCreateExecutionModel(t *testing.T) {
expectedSpecBytes, _ := proto.Marshal(expectedSpec)
assert.Equal(t, expectedSpecBytes, execution.Spec)
assert.Equal(t, execution.User, principal)
assert.Nil(t, execution.ErrorKind)
assert.Nil(t, execution.ErrorCode)

expectedCreatedAt, _ := ptypes.TimestampProto(createdAt)
expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{
Expand Down Expand Up @@ -172,6 +174,10 @@ func TestCreateExecutionModel(t *testing.T) {
expectedSpecBytes, _ := proto.Marshal(expectedSpec)
assert.Equal(t, expectedSpecBytes, execution.Spec)
assert.Equal(t, execution.User, principal)
assert.NotNil(t, execution.ErrorKind)
assert.Equal(t, core.ExecutionError_SYSTEM.String(), *execution.ErrorKind)
assert.NotNil(t, execution.ErrorCode)
assert.Equal(t, "Unknown", *execution.ErrorCode)

expectedCreatedAt, _ := ptypes.TimestampProto(createdAt)
expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{
Expand Down Expand Up @@ -238,6 +244,10 @@ func TestCreateExecutionModel(t *testing.T) {
expectedSpecBytes, _ := proto.Marshal(expectedSpec)
assert.Equal(t, expectedSpecBytes, execution.Spec)
assert.Equal(t, execution.User, principal)
assert.NotNil(t, execution.ErrorKind)
assert.Equal(t, core.ExecutionError_USER.String(), *execution.ErrorKind)
assert.NotNil(t, execution.ErrorCode)
assert.Equal(t, codes.InvalidArgument.String(), *execution.ErrorCode)

expectedCreatedAt, _ := ptypes.TimestampProto(createdAt)
expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{
Expand Down Expand Up @@ -304,6 +314,10 @@ func TestCreateExecutionModel(t *testing.T) {
expectedSpecBytes, _ := proto.Marshal(expectedSpec)
assert.Equal(t, expectedSpecBytes, execution.Spec)
assert.Equal(t, execution.User, principal)
assert.NotNil(t, execution.ErrorKind)
assert.Equal(t, core.ExecutionError_SYSTEM.String(), *execution.ErrorKind)
assert.NotNil(t, execution.ErrorCode)
assert.Equal(t, codes.Internal.String(), *execution.ErrorCode)

expectedCreatedAt, _ := ptypes.TimestampProto(createdAt)
expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{
Expand Down
Loading