Skip to content

Commit

Permalink
improve code quality
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Wu <[email protected]>
  • Loading branch information
popojk committed Jan 19, 2025
1 parent 4414f89 commit 3ed4177
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions flytepropeller/pkg/controller/nodes/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 776 in flytepropeller/pkg/controller/nodes/executor.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/executor.go#L771-L776

Added lines #L771 - L776 were not covered by tests
}
Expand Down
5 changes: 3 additions & 2 deletions flytepropeller/pkg/controller/nodes/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down
7 changes: 5 additions & 2 deletions flytepropeller/pkg/utils/assert/literals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Check warning on line 21 in flytepropeller/pkg/utils/assert/literals.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/utils/assert/literals.go#L20-L21

Added lines #L20 - L21 were not covered by tests
}

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) {
Expand Down

0 comments on commit 3ed4177

Please sign in to comment.