This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
BugFix: SubWorkflow and dynamic node handling failure #84
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4f22b68
Handling Finalize for subworkflows
d9cca92
config change
1de1b01
improved logging
4aebcdd
Fixing the regression
77943cf
updated and fixed tests
31bfde0
comment updated
db549c0
updated
44a7a94
More unit tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -4,11 +4,12 @@ import ( | |
"context" | ||
"fmt" | ||
|
||
"github.com/lyft/flytestdlib/storage" | ||
|
||
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
"github.com/lyft/flytepropeller/pkg/controller/executors" | ||
"github.com/lyft/flytepropeller/pkg/controller/nodes/errors" | ||
"github.com/lyft/flytepropeller/pkg/controller/nodes/handler" | ||
"github.com/lyft/flytestdlib/storage" | ||
) | ||
|
||
// TODO Add unit tests for subworkflow handler | ||
|
@@ -174,7 +175,7 @@ func (s *subworkflowHandler) HandleSubWorkflowFailingNode(ctx context.Context, n | |
return s.DoInFailureHandling(ctx, nCtx, contextualSubWorkflow) | ||
} | ||
|
||
func (s *subworkflowHandler) HandleAbort(ctx context.Context, nCtx handler.NodeExecutionContext, w v1alpha1.ExecutableWorkflow, workflowID v1alpha1.WorkflowID) error { | ||
func (s *subworkflowHandler) HandleAbort(ctx context.Context, nCtx handler.NodeExecutionContext, w v1alpha1.ExecutableWorkflow, workflowID v1alpha1.WorkflowID, reason string) error { | ||
subWorkflow := w.FindSubWorkflow(workflowID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. contextual parent |
||
if subWorkflow == nil { | ||
return fmt.Errorf("no sub workflow [%s] found in node [%s]", workflowID, nCtx.NodeID()) | ||
|
@@ -183,12 +184,12 @@ func (s *subworkflowHandler) HandleAbort(ctx context.Context, nCtx handler.NodeE | |
nodeStatus := w.GetNodeExecutionStatus(ctx, nCtx.NodeID()) | ||
contextualSubWorkflow := executors.NewSubContextualWorkflow(w, subWorkflow, nodeStatus) | ||
|
||
startNode := w.StartNode() | ||
startNode := contextualSubWorkflow.StartNode() | ||
if startNode == nil { | ||
return fmt.Errorf("no sub workflow [%s] found in node [%s]", workflowID, nCtx.NodeID()) | ||
} | ||
|
||
return s.nodeExecutor.AbortHandler(ctx, contextualSubWorkflow, startNode, "") | ||
return s.nodeExecutor.AbortHandler(ctx, contextualSubWorkflow, startNode, reason) | ||
} | ||
|
||
func newSubworkflowHandler(nodeExecutor executors.Node) subworkflowHandler { | ||
|
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,78 @@ | ||
package subworkflow | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
|
||
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
coreMocks "github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1/mocks" | ||
execMocks "github.com/lyft/flytepropeller/pkg/controller/executors/mocks" | ||
"github.com/lyft/flytepropeller/pkg/controller/nodes/handler/mocks" | ||
) | ||
|
||
func Test_subworkflowHandler_HandleAbort(t *testing.T) { | ||
ctx := context.TODO() | ||
|
||
t.Run("missing-subworkflow", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(nil) | ||
nCtx.OnNodeID().Return("n1") | ||
assert.Error(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
|
||
t.Run("missing-startNode", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
st := &coreMocks.ExecutableNodeStatus{} | ||
swf := &coreMocks.ExecutableSubWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(swf) | ||
wf.OnGetNodeExecutionStatus(ctx, "n1").Return(st) | ||
nCtx.OnNodeID().Return("n1") | ||
swf.OnStartNode().Return(nil) | ||
assert.Error(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
|
||
t.Run("abort-error", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
st := &coreMocks.ExecutableNodeStatus{} | ||
swf := &coreMocks.ExecutableSubWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(swf) | ||
wf.OnGetNodeExecutionStatus(ctx, "n1").Return(st) | ||
nCtx.OnNodeID().Return("n1") | ||
n := &coreMocks.ExecutableNode{} | ||
swf.OnStartNode().Return(n) | ||
nodeExec.OnAbortHandler(ctx, wf, n, "reason").Return(fmt.Errorf("err")) | ||
assert.Error(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
|
||
t.Run("abort-success", func(t *testing.T) { | ||
nCtx := &mocks.NodeExecutionContext{} | ||
nodeExec := &execMocks.Node{} | ||
s := newSubworkflowHandler(nodeExec) | ||
wf := &coreMocks.ExecutableWorkflow{} | ||
st := &coreMocks.ExecutableNodeStatus{} | ||
swf := &coreMocks.ExecutableSubWorkflow{} | ||
wf.OnFindSubWorkflow("x").Return(swf) | ||
wf.OnGetNodeExecutionStatus(ctx, "n1").Return(st) | ||
nCtx.OnNodeID().Return("n1") | ||
n := &coreMocks.ExecutableNode{} | ||
swf.OnStartNode().Return(n) | ||
swf.OnGetID().Return("swf") | ||
nodeExec.OnAbortHandlerMatch(mock.Anything, mock.MatchedBy(func(wf v1alpha1.ExecutableWorkflow) bool { | ||
return wf.GetID() == swf.GetID() | ||
}), n, mock.Anything).Return(nil) | ||
assert.NoError(t, s.HandleAbort(ctx, nCtx, wf, "x", "reason")) | ||
}) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add docs for why we should do it here and not after the handle() returns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup