-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kevin Su <[email protected]> Signed-off-by: Ketan Umare <[email protected]> Co-authored-by: Ketan Umare <[email protected]> Co-authored-by: Ketan Umare <[email protected]>
- Loading branch information
1 parent
b50ba87
commit 91d24a9
Showing
13 changed files
with
327 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
flytepropeller/pkg/controller/executors/failure_node_lookup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package executors | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/flyteorg/flyte/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
) | ||
|
||
type FailureNodeLookup struct { | ||
NodeLookup | ||
FailureNode v1alpha1.ExecutableNode | ||
FailureNodeStatus v1alpha1.ExecutableNodeStatus | ||
} | ||
|
||
func (f FailureNodeLookup) GetNode(nodeID v1alpha1.NodeID) (v1alpha1.ExecutableNode, bool) { | ||
if nodeID == v1alpha1.StartNodeID { | ||
return f.NodeLookup.GetNode(nodeID) | ||
} | ||
return f.FailureNode, true | ||
} | ||
|
||
func (f FailureNodeLookup) GetNodeExecutionStatus(ctx context.Context, id v1alpha1.NodeID) v1alpha1.ExecutableNodeStatus { | ||
if id == v1alpha1.StartNodeID { | ||
return f.NodeLookup.GetNodeExecutionStatus(ctx, id) | ||
} | ||
return f.FailureNodeStatus | ||
} | ||
|
||
func (f FailureNodeLookup) ToNode(id v1alpha1.NodeID) ([]v1alpha1.NodeID, error) { | ||
// The upstream node of the failure node is always the start node | ||
return []v1alpha1.NodeID{v1alpha1.StartNodeID}, nil | ||
} | ||
|
||
func (f FailureNodeLookup) FromNode(id v1alpha1.NodeID) ([]v1alpha1.NodeID, error) { | ||
return nil, nil | ||
} | ||
|
||
func NewFailureNodeLookup(nodeLookup NodeLookup, failureNode v1alpha1.ExecutableNode, failureNodeStatus v1alpha1.ExecutableNodeStatus) NodeLookup { | ||
return FailureNodeLookup{ | ||
NodeLookup: nodeLookup, | ||
FailureNode: failureNode, | ||
FailureNodeStatus: failureNodeStatus, | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
flytepropeller/pkg/controller/executors/failure_node_lookup_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package executors | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/flyteorg/flyte/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
"github.com/flyteorg/flyte/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type nl struct { | ||
NodeLookup | ||
} | ||
|
||
type en struct { | ||
v1alpha1.ExecutableNode | ||
} | ||
|
||
type ns struct { | ||
v1alpha1.ExecutableNodeStatus | ||
} | ||
|
||
func TestNewFailureNodeLookup(t *testing.T) { | ||
nl := nl{} | ||
en := en{} | ||
ns := ns{} | ||
nodeLoopUp := NewFailureNodeLookup(nl, en, ns) | ||
assert.NotNil(t, nl) | ||
typed := nodeLoopUp.(FailureNodeLookup) | ||
assert.Equal(t, nl, typed.NodeLookup) | ||
assert.Equal(t, en, typed.FailureNode) | ||
assert.Equal(t, ns, typed.FailureNodeStatus) | ||
} | ||
|
||
func TestNewTestFailureNodeLookup(t *testing.T) { | ||
n := &mocks.ExecutableNode{} | ||
ns := &mocks.ExecutableNodeStatus{} | ||
failureNodeID := "fn1" | ||
nl := NewTestNodeLookup( | ||
map[string]v1alpha1.ExecutableNode{v1alpha1.StartNodeID: n, failureNodeID: n}, | ||
map[string]v1alpha1.ExecutableNodeStatus{v1alpha1.StartNodeID: ns, failureNodeID: ns}, | ||
) | ||
|
||
assert.NotNil(t, nl) | ||
|
||
failureNodeLookup := NewFailureNodeLookup(nl, n, ns) | ||
r, ok := failureNodeLookup.GetNode(v1alpha1.StartNodeID) | ||
assert.True(t, ok) | ||
assert.Equal(t, n, r) | ||
assert.Equal(t, ns, failureNodeLookup.GetNodeExecutionStatus(context.TODO(), v1alpha1.StartNodeID)) | ||
|
||
r, ok = failureNodeLookup.GetNode(failureNodeID) | ||
assert.True(t, ok) | ||
assert.Equal(t, n, r) | ||
assert.Equal(t, ns, failureNodeLookup.GetNodeExecutionStatus(context.TODO(), failureNodeID)) | ||
|
||
nodeIDs, err := failureNodeLookup.ToNode(failureNodeID) | ||
assert.Equal(t, len(nodeIDs), 1) | ||
assert.Equal(t, nodeIDs[0], v1alpha1.StartNodeID) | ||
assert.Nil(t, err) | ||
|
||
nodeIDs, err = failureNodeLookup.FromNode(failureNodeID) | ||
assert.Nil(t, nodeIDs) | ||
assert.Nil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.