From ebae8c82d1cb7c758ff99b63e6319c860404fd7e Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 10:58:53 -0700 Subject: [PATCH 1/9] Add some logging Signed-off-by: Katrina Rogan --- pkg/manager/impl/node_execution_manager.go | 7 +++++++ pkg/repositories/transformers/execution.go | 3 +++ pkg/repositories/transformers/node_execution.go | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/pkg/manager/impl/node_execution_manager.go b/pkg/manager/impl/node_execution_manager.go index bcc4362db..1e29d7e8d 100644 --- a/pkg/manager/impl/node_execution_manager.go +++ b/pkg/manager/impl/node_execution_manager.go @@ -408,11 +408,18 @@ func (m *NodeExecutionManager) listNodeExecutions( if len(output.NodeExecutions) == int(limit) { token = strconv.Itoa(offset + len(output.NodeExecutions)) } + logger.Infof(ctx, "using [%s] as pagination token", token) + logger.Infof(ctx, "transforming node executions [%+v]", output.NodeExecutions) nodeExecutionList, err := m.transformNodeExecutionModelList(ctx, output.NodeExecutions) if err != nil { logger.Debugf(ctx, "failed to transform node execution models for request with err: %v", err) return nil, err } + logger.Infof(ctx, "node execution models are [%+v]", nodeExecutionList) + logger.Infof(ctx, "would return response [%+v]", &admin.NodeExecutionList{ + NodeExecutions: nodeExecutionList, + Token: token, + }) return &admin.NodeExecutionList{ NodeExecutions: nodeExecutionList, diff --git a/pkg/repositories/transformers/execution.go b/pkg/repositories/transformers/execution.go index f9e626ebf..4b17217d6 100644 --- a/pkg/repositories/transformers/execution.go +++ b/pkg/repositories/transformers/execution.go @@ -342,11 +342,14 @@ func FromExecutionModel(ctx context.Context, executionModel models.Execution, op if err = proto.Unmarshal(executionModel.Closure, &closure); err != nil { return nil, errors.NewFlyteAdminErrorf(codes.Internal, "failed to unmarshal closure") } + logger.Infof(ctx, "possibly trimming error message for [%+v]", executionModel.ExecutionKey) if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() + logger.Infof(ctx, "overwriting original error message [%+v]", trimmedErrOutputResult.Message) if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] } + logger.Infof(ctx, "with trimmed message [%+v]", trimmedErrOutputResult) closure.OutputResult = &admin.ExecutionClosure_Error{ Error: trimmedErrOutputResult, } diff --git a/pkg/repositories/transformers/node_execution.go b/pkg/repositories/transformers/node_execution.go index f1d90361f..fbaf36b52 100644 --- a/pkg/repositories/transformers/node_execution.go +++ b/pkg/repositories/transformers/node_execution.go @@ -321,11 +321,17 @@ func FromNodeExecutionModel(nodeExecutionModel models.NodeExecution, opts *Execu if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.Internal, "failed to unmarshal closure") } + + ctx := context.TODO() + logger.Infof(ctx, "possibly trimming error message for [%+v]", nodeExecutionModel.NodeExecutionKey) if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() + + logger.Infof(context.TODO(), "overwriting original error message [%+v]", trimmedErrOutputResult.Message) if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] } + logger.Infof(ctx, "with trimmed message [%+v]", trimmedErrOutputResult) closure.OutputResult = &admin.NodeExecutionClosure_Error{ Error: trimmedErrOutputResult, } From 435ee01907b2a26ecc5a573eb50dfab5b8b88891 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:08:36 -0700 Subject: [PATCH 2/9] ensure trimmed error messages are valid utf-8 Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/execution.go | 3 -- .../transformers/execution_test.go | 32 +++++++++++++++++++ .../transformers/node_execution.go | 6 ---- .../transformers/node_execution_test.go | 5 ++- .../transformers/task_execution.go | 5 ++- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/pkg/repositories/transformers/execution.go b/pkg/repositories/transformers/execution.go index 4b17217d6..f9e626ebf 100644 --- a/pkg/repositories/transformers/execution.go +++ b/pkg/repositories/transformers/execution.go @@ -342,14 +342,11 @@ func FromExecutionModel(ctx context.Context, executionModel models.Execution, op if err = proto.Unmarshal(executionModel.Closure, &closure); err != nil { return nil, errors.NewFlyteAdminErrorf(codes.Internal, "failed to unmarshal closure") } - logger.Infof(ctx, "possibly trimming error message for [%+v]", executionModel.ExecutionKey) if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() - logger.Infof(ctx, "overwriting original error message [%+v]", trimmedErrOutputResult.Message) if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] } - logger.Infof(ctx, "with trimmed message [%+v]", trimmedErrOutputResult) closure.OutputResult = &admin.ExecutionClosure_Error{ Error: trimmedErrOutputResult, } diff --git a/pkg/repositories/transformers/execution_test.go b/pkg/repositories/transformers/execution_test.go index 43073deb4..6f26333c7 100644 --- a/pkg/repositories/transformers/execution_test.go +++ b/pkg/repositories/transformers/execution_test.go @@ -6,6 +6,7 @@ import ( "strings" "testing" "time" + "unicode/utf8" "github.com/flyteorg/flyteadmin/pkg/common" @@ -602,6 +603,30 @@ func TestFromExecutionModel_Error(t *testing.T) { assert.True(t, proto.Equal(expectedExecErr, execution.Closure.GetError())) } +func TestFromExecutionModel_ValidUTF8TrimmedErrorMsg(t *testing.T) { + errMsg := "[1/1] currentAttempt done. Last Error: USER:: │\n│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │\n│ │\n│ /usr/local/lib/python3.10/site-packages/flytekit/bin/entrypoint.py:508 in │\n│ fast_execute_task_cmd │\n│ │\n│ ❱ 508 │ subprocess.run(cmd, check=True) │\n│ │\n│ /usr/local/lib/python3.10/subprocess.py:526 in run │\n│ │\n│ ❱ 526 │ │ │ raise CalledProcessError(retcode, process.args, │\n╰──────────────────────────────────────────────────────────────────────────────╯\nCalledProcessError: Command '['pyflyte-execute', '--inputs', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/inputs.pb', '--output-prefix', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/0', '--raw-output-data-prefix', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0', \n'--checkpoint-path', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0/_flytecheckpoints', \n'--prev-checkpoint', '\"\"', '--dynamic-addl-distro', \n's3://union-oc-production-demo/flytetester/development/IGBXBBQ4ZJWPO32U2HLEJKUA2\nU======/fast546b1d707386b561ac69681c08470be5.tar.gz', '--dynamic-dest-dir', \n'/root', '--resolver', \n'flytekit.core.python_auto_container.default_task_resolver', '--', \n'task-module', 'workflows.example', 'task-name', 'get_pandas_dataframe']' \nreturned non-zero exit status 1.\n" + + executionClosureBytes, _ := proto.Marshal(&admin.ExecutionClosure{ + Phase: core.WorkflowExecution_FAILED, + OutputResult: &admin.ExecutionClosure_Error{Error: &core.ExecutionError{Message: errMsg}}, + }) + executionModel := models.Execution{ + ExecutionKey: models.ExecutionKey{ + Project: "project", + Domain: "domain", + Name: "name", + }, + Phase: core.WorkflowExecution_FAILED.String(), + Closure: executionClosureBytes, + } + execution, err := FromExecutionModel(context.TODO(), executionModel, &ExecutionTransformerOptions{ + TrimErrorMessage: true, + }) + assert.NoError(t, err) + errMsgAreValidUTF8 := utf8.Valid([]byte(execution.GetClosure().GetError().GetMessage())) + assert.True(t, errMsgAreValidUTF8) +} + func TestFromExecutionModel_OverwriteNamespace(t *testing.T) { abortCause := "abort cause" executionClosureBytes, _ := proto.Marshal(&admin.ExecutionClosure{ @@ -875,3 +900,10 @@ func TestUpdateExecutionModelStateChangeDetails(t *testing.T) { assert.False(t, strings.Contains(err.Error(), "Failed to unmarshal execution closure")) }) } + +func TestTrimErrorMessage(t *testing.T) { + errMsg := "[1/1] currentAttempt done. Last Error: USER:: │\n│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │\n│ │\n│ /usr/local/lib/python3.10/site-packages/flytekit/bin/entrypoint.py:508 in │\n│ fast_execute_task_cmd │\n│ │\n│ ❱ 508 │ subprocess.run(cmd, check=True) │\n│ │\n│ /usr/local/lib/python3.10/subprocess.py:526 in run │\n│ │\n│ ❱ 526 │ │ │ raise CalledProcessError(retcode, process.args, │\n╰──────────────────────────────────────────────────────────────────────────────╯\nCalledProcessError: Command '['pyflyte-execute', '--inputs', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/inputs.pb', '--output-prefix', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/0', '--raw-output-data-prefix', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0', \n'--checkpoint-path', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0/_flytecheckpoints', \n'--prev-checkpoint', '\"\"', '--dynamic-addl-distro', \n's3://union-oc-production-demo/flytetester/development/IGBXBBQ4ZJWPO32U2HLEJKUA2\nU======/fast546b1d707386b561ac69681c08470be5.tar.gz', '--dynamic-dest-dir', \n'/root', '--resolver', \n'flytekit.core.python_auto_container.default_task_resolver', '--', \n'task-module', 'workflows.example', 'task-name', 'get_pandas_dataframe']' \nreturned non-zero exit status 1.\n" + trimmedErrMessage := TrimErrorMessage(errMsg) + errMsgAreValidUTF8 := utf8.Valid([]byte(trimmedErrMessage)) + assert.True(t, errMsgAreValidUTF8) +} diff --git a/pkg/repositories/transformers/node_execution.go b/pkg/repositories/transformers/node_execution.go index fbaf36b52..f1d90361f 100644 --- a/pkg/repositories/transformers/node_execution.go +++ b/pkg/repositories/transformers/node_execution.go @@ -321,17 +321,11 @@ func FromNodeExecutionModel(nodeExecutionModel models.NodeExecution, opts *Execu if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.Internal, "failed to unmarshal closure") } - - ctx := context.TODO() - logger.Infof(ctx, "possibly trimming error message for [%+v]", nodeExecutionModel.NodeExecutionKey) if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() - - logger.Infof(context.TODO(), "overwriting original error message [%+v]", trimmedErrOutputResult.Message) if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] } - logger.Infof(ctx, "with trimmed message [%+v]", trimmedErrOutputResult) closure.OutputResult = &admin.NodeExecutionClosure_Error{ Error: trimmedErrOutputResult, } diff --git a/pkg/repositories/transformers/node_execution_test.go b/pkg/repositories/transformers/node_execution_test.go index 88ef8fc26..32d984c25 100644 --- a/pkg/repositories/transformers/node_execution_test.go +++ b/pkg/repositories/transformers/node_execution_test.go @@ -2,11 +2,10 @@ package transformers import ( "context" - "testing" - "time" - "github.com/flyteorg/flyteidl/clients/go/coreutils" "github.com/flyteorg/flytestdlib/promutils" + "testing" + "time" flyteAdminErrors "github.com/flyteorg/flyteadmin/pkg/errors" "google.golang.org/grpc/codes" diff --git a/pkg/repositories/transformers/task_execution.go b/pkg/repositories/transformers/task_execution.go index f57f4b6b3..edfc32b19 100644 --- a/pkg/repositories/transformers/task_execution.go +++ b/pkg/repositories/transformers/task_execution.go @@ -444,9 +444,8 @@ func FromTaskExecutionModel(taskExecutionModel models.TaskExecution, opts *Execu } if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() - if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { - trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] - } + trimmedErrMessage := TrimErrorMessage(trimmedErrOutputResult.GetMessage()) + trimmedErrOutputResult.Message = trimmedErrMessage closure.OutputResult = &admin.TaskExecutionClosure_Error{ Error: trimmedErrOutputResult, } From b9b0d23ebb32c040dad8d132cef2d46beaad4ed4 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:09:49 -0700 Subject: [PATCH 3/9] fix Signed-off-by: Katrina Rogan --- pkg/manager/impl/node_execution_manager.go | 7 ------- pkg/repositories/transformers/execution.go | 18 +++++++++++++++--- .../transformers/node_execution.go | 9 ++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pkg/manager/impl/node_execution_manager.go b/pkg/manager/impl/node_execution_manager.go index 1e29d7e8d..bcc4362db 100644 --- a/pkg/manager/impl/node_execution_manager.go +++ b/pkg/manager/impl/node_execution_manager.go @@ -408,18 +408,11 @@ func (m *NodeExecutionManager) listNodeExecutions( if len(output.NodeExecutions) == int(limit) { token = strconv.Itoa(offset + len(output.NodeExecutions)) } - logger.Infof(ctx, "using [%s] as pagination token", token) - logger.Infof(ctx, "transforming node executions [%+v]", output.NodeExecutions) nodeExecutionList, err := m.transformNodeExecutionModelList(ctx, output.NodeExecutions) if err != nil { logger.Debugf(ctx, "failed to transform node execution models for request with err: %v", err) return nil, err } - logger.Infof(ctx, "node execution models are [%+v]", nodeExecutionList) - logger.Infof(ctx, "would return response [%+v]", &admin.NodeExecutionList{ - NodeExecutions: nodeExecutionList, - Token: token, - }) return &admin.NodeExecutionList{ NodeExecutions: nodeExecutionList, diff --git a/pkg/repositories/transformers/execution.go b/pkg/repositories/transformers/execution.go index f9e626ebf..50d70c3c8 100644 --- a/pkg/repositories/transformers/execution.go +++ b/pkg/repositories/transformers/execution.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" "time" + "unicode/utf8" "github.com/flyteorg/flyteadmin/pkg/common" "github.com/flyteorg/flyteadmin/pkg/errors" @@ -344,9 +345,8 @@ func FromExecutionModel(ctx context.Context, executionModel models.Execution, op } if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() - if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { - trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] - } + trimmedErrMessage := TrimErrorMessage(trimmedErrOutputResult.GetMessage()) + trimmedErrOutputResult.Message = trimmedErrMessage closure.OutputResult = &admin.ExecutionClosure_Error{ Error: trimmedErrOutputResult, } @@ -409,3 +409,15 @@ func FromExecutionModels(ctx context.Context, executionModels []models.Execution } return executions, nil } + +// TrimErrorMessage return the smallest possible trimmed error message >= trimmedErrMessageLen bytes in length that still forms a valid utf-8 string +func TrimErrorMessage(errMsg string) string { + if len(errMsg) < trimmedErrMessageLen { + return errMsg + } + minLength := trimmedErrMessageLen + for len(errMsg) >= minLength && utf8.ValidString(errMsg[:minLength]) == false { + minLength++ + } + return errMsg[:minLength] +} diff --git a/pkg/repositories/transformers/node_execution.go b/pkg/repositories/transformers/node_execution.go index f1d90361f..0730d9e7d 100644 --- a/pkg/repositories/transformers/node_execution.go +++ b/pkg/repositories/transformers/node_execution.go @@ -321,11 +321,14 @@ func FromNodeExecutionModel(nodeExecutionModel models.NodeExecution, opts *Execu if err != nil { return nil, errors.NewFlyteAdminErrorf(codes.Internal, "failed to unmarshal closure") } + + ctx := context.TODO() + logger.Infof(ctx, "possibly trimming error message for [%+v]", nodeExecutionModel.NodeExecutionKey) if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() - if len(trimmedErrOutputResult.Message) > trimmedErrMessageLen { - trimmedErrOutputResult.Message = trimmedErrOutputResult.Message[0:trimmedErrMessageLen] - } + trimmedErrMessage := TrimErrorMessage(trimmedErrOutputResult.GetMessage()) + trimmedErrOutputResult.Message = trimmedErrMessage + logger.Infof(ctx, "with trimmed message [%+v]", trimmedErrOutputResult) closure.OutputResult = &admin.NodeExecutionClosure_Error{ Error: trimmedErrOutputResult, } From 907b60f179ffdd6c58e12a45afda66f2500d857f Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:10:40 -0700 Subject: [PATCH 4/9] log Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/node_execution.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/repositories/transformers/node_execution.go b/pkg/repositories/transformers/node_execution.go index 0730d9e7d..7eb57a70b 100644 --- a/pkg/repositories/transformers/node_execution.go +++ b/pkg/repositories/transformers/node_execution.go @@ -322,13 +322,10 @@ func FromNodeExecutionModel(nodeExecutionModel models.NodeExecution, opts *Execu return nil, errors.NewFlyteAdminErrorf(codes.Internal, "failed to unmarshal closure") } - ctx := context.TODO() - logger.Infof(ctx, "possibly trimming error message for [%+v]", nodeExecutionModel.NodeExecutionKey) if closure.GetError() != nil && opts != nil && opts.TrimErrorMessage && len(closure.GetError().Message) > 0 { trimmedErrOutputResult := closure.GetError() trimmedErrMessage := TrimErrorMessage(trimmedErrOutputResult.GetMessage()) trimmedErrOutputResult.Message = trimmedErrMessage - logger.Infof(ctx, "with trimmed message [%+v]", trimmedErrOutputResult) closure.OutputResult = &admin.NodeExecutionClosure_Error{ Error: trimmedErrOutputResult, } From 219f4bc33836cda930112b098a0cbe212dd7b83a Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:24:34 -0700 Subject: [PATCH 5/9] simpler test Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/execution_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/repositories/transformers/execution_test.go b/pkg/repositories/transformers/execution_test.go index 6f26333c7..215d700c2 100644 --- a/pkg/repositories/transformers/execution_test.go +++ b/pkg/repositories/transformers/execution_test.go @@ -604,7 +604,7 @@ func TestFromExecutionModel_Error(t *testing.T) { } func TestFromExecutionModel_ValidUTF8TrimmedErrorMsg(t *testing.T) { - errMsg := "[1/1] currentAttempt done. Last Error: USER:: │\n│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │\n│ │\n│ /usr/local/lib/python3.10/site-packages/flytekit/bin/entrypoint.py:508 in │\n│ fast_execute_task_cmd │\n│ │\n│ ❱ 508 │ subprocess.run(cmd, check=True) │\n│ │\n│ /usr/local/lib/python3.10/subprocess.py:526 in run │\n│ │\n│ ❱ 526 │ │ │ raise CalledProcessError(retcode, process.args, │\n╰──────────────────────────────────────────────────────────────────────────────╯\nCalledProcessError: Command '['pyflyte-execute', '--inputs', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/inputs.pb', '--output-prefix', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/0', '--raw-output-data-prefix', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0', \n'--checkpoint-path', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0/_flytecheckpoints', \n'--prev-checkpoint', '\"\"', '--dynamic-addl-distro', \n's3://union-oc-production-demo/flytetester/development/IGBXBBQ4ZJWPO32U2HLEJKUA2\nU======/fast546b1d707386b561ac69681c08470be5.tar.gz', '--dynamic-dest-dir', \n'/root', '--resolver', \n'flytekit.core.python_auto_container.default_task_resolver', '--', \n'task-module', 'workflows.example', 'task-name', 'get_pandas_dataframe']' \nreturned non-zero exit status 1.\n" + errMsg := "[1/1] currentAttempt done. Last Error: USER:: │\n│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │\n││" executionClosureBytes, _ := proto.Marshal(&admin.ExecutionClosure{ Phase: core.WorkflowExecution_FAILED, @@ -902,7 +902,7 @@ func TestUpdateExecutionModelStateChangeDetails(t *testing.T) { } func TestTrimErrorMessage(t *testing.T) { - errMsg := "[1/1] currentAttempt done. Last Error: USER:: │\n│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │\n│ │\n│ /usr/local/lib/python3.10/site-packages/flytekit/bin/entrypoint.py:508 in │\n│ fast_execute_task_cmd │\n│ │\n│ ❱ 508 │ subprocess.run(cmd, check=True) │\n│ │\n│ /usr/local/lib/python3.10/subprocess.py:526 in run │\n│ │\n│ ❱ 526 │ │ │ raise CalledProcessError(retcode, process.args, │\n╰──────────────────────────────────────────────────────────────────────────────╯\nCalledProcessError: Command '['pyflyte-execute', '--inputs', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/inputs.pb', '--output-prefix', \n's3://union-oc-production-demo/metadata/propeller/flytetester-development-awh8z9\nwmnc5hlp687vdn/n0/data/0', '--raw-output-data-prefix', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0', \n'--checkpoint-path', \n's3://union-oc-production-demo/v7/awh8z9wmnc5hlp687vdn-n0-0/_flytecheckpoints', \n'--prev-checkpoint', '\"\"', '--dynamic-addl-distro', \n's3://union-oc-production-demo/flytetester/development/IGBXBBQ4ZJWPO32U2HLEJKUA2\nU======/fast546b1d707386b561ac69681c08470be5.tar.gz', '--dynamic-dest-dir', \n'/root', '--resolver', \n'flytekit.core.python_auto_container.default_task_resolver', '--', \n'task-module', 'workflows.example', 'task-name', 'get_pandas_dataframe']' \nreturned non-zero exit status 1.\n" + errMsg := "[1/1] currentAttempt done. Last Error: USER:: │\n│ ❱ 760 │ │ │ │ return __callback(*args, **kwargs) │\n││" trimmedErrMessage := TrimErrorMessage(errMsg) errMsgAreValidUTF8 := utf8.Valid([]byte(trimmedErrMessage)) assert.True(t, errMsgAreValidUTF8) From f6d681bfa1b0e106053a40541b05e47c0622a9cf Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:34:44 -0700 Subject: [PATCH 6/9] lint Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/execution.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/repositories/transformers/execution.go b/pkg/repositories/transformers/execution.go index 50d70c3c8..d70d4966b 100644 --- a/pkg/repositories/transformers/execution.go +++ b/pkg/repositories/transformers/execution.go @@ -416,7 +416,7 @@ func TrimErrorMessage(errMsg string) string { return errMsg } minLength := trimmedErrMessageLen - for len(errMsg) >= minLength && utf8.ValidString(errMsg[:minLength]) == false { + for len(errMsg) >= minLength && !utf8.ValidString(errMsg[:minLength]) { minLength++ } return errMsg[:minLength] From 3f1590c954894b80c8dfd3290169e428d73c7201 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:42:39 -0700 Subject: [PATCH 7/9] fmt Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/node_execution_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/repositories/transformers/node_execution_test.go b/pkg/repositories/transformers/node_execution_test.go index 32d984c25..88ef8fc26 100644 --- a/pkg/repositories/transformers/node_execution_test.go +++ b/pkg/repositories/transformers/node_execution_test.go @@ -2,11 +2,12 @@ package transformers import ( "context" - "github.com/flyteorg/flyteidl/clients/go/coreutils" - "github.com/flyteorg/flytestdlib/promutils" "testing" "time" + "github.com/flyteorg/flyteidl/clients/go/coreutils" + "github.com/flyteorg/flytestdlib/promutils" + flyteAdminErrors "github.com/flyteorg/flyteadmin/pkg/errors" "google.golang.org/grpc/codes" From f8144c7f4b6465ae84ee1ff8ae93a5c29a1d7e96 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:50:21 -0700 Subject: [PATCH 8/9] use lib method Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/execution.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/repositories/transformers/execution.go b/pkg/repositories/transformers/execution.go index d70d4966b..c1730929b 100644 --- a/pkg/repositories/transformers/execution.go +++ b/pkg/repositories/transformers/execution.go @@ -3,10 +3,6 @@ package transformers import ( "context" "fmt" - "strings" - "time" - "unicode/utf8" - "github.com/flyteorg/flyteadmin/pkg/common" "github.com/flyteorg/flyteadmin/pkg/errors" "github.com/flyteorg/flyteadmin/pkg/repositories/models" @@ -17,6 +13,8 @@ import ( "github.com/flyteorg/flytestdlib/storage" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" + "strings" + "time" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/timestamppb" @@ -412,12 +410,8 @@ func FromExecutionModels(ctx context.Context, executionModels []models.Execution // TrimErrorMessage return the smallest possible trimmed error message >= trimmedErrMessageLen bytes in length that still forms a valid utf-8 string func TrimErrorMessage(errMsg string) string { - if len(errMsg) < trimmedErrMessageLen { + if len(errMsg) <= trimmedErrMessageLen { return errMsg } - minLength := trimmedErrMessageLen - for len(errMsg) >= minLength && !utf8.ValidString(errMsg[:minLength]) { - minLength++ - } - return errMsg[:minLength] + return strings.ToValidUTF8(errMsg[:trimmedErrMessageLen], "") } From d81f291e8e770e21a8a756d2a2ccd3953a0cec61 Mon Sep 17 00:00:00 2001 From: Katrina Rogan Date: Tue, 30 May 2023 12:57:34 -0700 Subject: [PATCH 9/9] fmt Signed-off-by: Katrina Rogan --- pkg/repositories/transformers/execution.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/repositories/transformers/execution.go b/pkg/repositories/transformers/execution.go index c1730929b..de0d986af 100644 --- a/pkg/repositories/transformers/execution.go +++ b/pkg/repositories/transformers/execution.go @@ -3,6 +3,9 @@ package transformers import ( "context" "fmt" + "strings" + "time" + "github.com/flyteorg/flyteadmin/pkg/common" "github.com/flyteorg/flyteadmin/pkg/errors" "github.com/flyteorg/flyteadmin/pkg/repositories/models" @@ -13,8 +16,6 @@ import ( "github.com/flyteorg/flytestdlib/storage" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" - "strings" - "time" "google.golang.org/grpc/codes" "google.golang.org/protobuf/types/known/timestamppb"