From 3ed417774fbbc77c73db6ba20bc2254fc0c7d5e4 Mon Sep 17 00:00:00 2001 From: Alex Wu Date: Sun, 19 Jan 2025 12:01:28 +0800 Subject: [PATCH] improve code quality Signed-off-by: Alex Wu --- flytepropeller/pkg/controller/nodes/executor.go | 6 ++++-- flytepropeller/pkg/controller/nodes/resolve_test.go | 5 +++-- flytepropeller/pkg/utils/assert/literals.go | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/flytepropeller/pkg/controller/nodes/executor.go b/flytepropeller/pkg/controller/nodes/executor.go index f6fec1a123..f947ea69b7 100644 --- a/flytepropeller/pkg/controller/nodes/executor.go +++ b/flytepropeller/pkg/controller/nodes/executor.go @@ -768,8 +768,10 @@ func (c *nodeExecutor) preExecute(ctx context.Context, dag executors.DAGStructur // Resolve error input if current node is an on failure node failureNodeLookup, ok := nCtx.ContextualNodeLookup().(executors.FailureNodeLookup) if ok { - originalErr, _ := failureNodeLookup.GetOriginalError() - if originalErr != nil { + originalErr, err := failureNodeLookup.GetOriginalError() + if err != nil { + return handler.PhaseInfoFailure(core.ExecutionError_SYSTEM, "FailureNodeError", err.Error(), nil), nil + } else if originalErr != nil { ResolveOnFailureNodeInput(ctx, nodeInputs, node.GetID(), originalErr) } } diff --git a/flytepropeller/pkg/controller/nodes/resolve_test.go b/flytepropeller/pkg/controller/nodes/resolve_test.go index 6ab119cd03..dbfd7bf5a0 100644 --- a/flytepropeller/pkg/controller/nodes/resolve_test.go +++ b/flytepropeller/pkg/controller/nodes/resolve_test.go @@ -468,7 +468,7 @@ func TestResolve(t *testing.T) { } -func TestResolveErrorInput(t *testing.T) { +func TestResolveOnFailureNodeInput(t *testing.T) { ctx := context.Background() t.Run("ResolveErrorInputs", func(t *testing.T) { noneLiteral, _ := coreutils.MakeLiteral(nil) @@ -500,7 +500,8 @@ func TestResolveErrorInput(t *testing.T) { Message: "node failure", } expectedLiterals := make(map[string]*core.Literal, 1) - errorLiteral, _ := coreutils.MakeLiteral(&core.Error{Message: execErr.GetMessage(), FailedNodeId: nID}) + errorLiteral, err := coreutils.MakeLiteral(&core.Error{Message: execErr.GetMessage(), FailedNodeId: nID}) + assert.NoError(t, err) expectedLiterals["err"] = &core.Literal{ Value: &core.Literal_Scalar{ Scalar: &core.Scalar{ diff --git a/flytepropeller/pkg/utils/assert/literals.go b/flytepropeller/pkg/utils/assert/literals.go index 31c5d2e846..6e9a049b56 100644 --- a/flytepropeller/pkg/utils/assert/literals.go +++ b/flytepropeller/pkg/utils/assert/literals.go @@ -20,8 +20,11 @@ func EqualLiteralType(t *testing.T, lt1 *core.LiteralType, lt2 *core.LiteralType default: assert.FailNow(t, "Not yet implemented for types %v", reflect.TypeOf(lt1.GetType())) } - - assert.Equal(t, lt1.GetStructure().GetTag(), lt2.GetStructure().GetTag()) + structure1 := lt1.GetStructure() + structure2 := lt2.GetStructure() + if structure1 != nil && structure2 != nil { + assert.Equal(t, structure1.GetTag(), structure2.GetTag()) + } } func EqualPrimitive(t *testing.T, p1 *core.Primitive, p2 *core.Primitive) {