Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

bug; abort called for not started nodes #140

Merged
merged 1 commit into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/controller/nodes/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,12 @@ func (c *nodeExecutor) FinalizeHandler(ctx context.Context, execContext executor
nodeStatus := nl.GetNodeExecutionStatus(ctx, currentNode.GetID())
nodePhase := nodeStatus.GetPhase()

if nodePhase == v1alpha1.NodePhaseNotYetStarted {
logger.Infof(ctx, "Node not yet started, will not finalize")
// Nothing to be aborted
return nil
}

if canHandleNode(nodePhase) {
ctx = contextutils.WithNodeID(ctx, currentNode.GetID())

Expand Down Expand Up @@ -721,6 +727,13 @@ func (c *nodeExecutor) FinalizeHandler(ctx context.Context, execContext executor
func (c *nodeExecutor) AbortHandler(ctx context.Context, execContext executors.ExecutionContext, dag executors.DAGStructure, nl executors.NodeLookup, currentNode v1alpha1.ExecutableNode, reason string) error {
nodeStatus := nl.GetNodeExecutionStatus(ctx, currentNode.GetID())
nodePhase := nodeStatus.GetPhase()

if nodePhase == v1alpha1.NodePhaseNotYetStarted {
logger.Infof(ctx, "Node not yet started, will not finalize")
// Nothing to be aborted
return nil
}

if canHandleNode(nodePhase) {
ctx = contextutils.WithNodeID(ctx, currentNode.GetID())

Expand Down
32 changes: 32 additions & 0 deletions pkg/controller/nodes/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1523,3 +1523,35 @@ func Test_nodeExecutor_abort(t *testing.T) {
assert.True(t, called)
})
}

func TestNodeExecutor_AbortHandler(t *testing.T) {
ctx := context.Background()
exec := nodeExecutor{}

t.Run("not-yet-started", func(t *testing.T) {
id := "id"
n := &mocks.ExecutableNode{}
n.OnGetID().Return(id)
nl := &mocks4.NodeLookup{}
ns := &mocks.ExecutableNodeStatus{}
ns.OnGetPhase().Return(v1alpha1.NodePhaseNotYetStarted)
nl.OnGetNodeExecutionStatusMatch(mock.Anything, id).Return(ns)
assert.NoError(t, exec.AbortHandler(ctx, nil, nil, nl, n, "aborting"))
})
}

func TestNodeExecutor_FinalizeHandler(t *testing.T) {
ctx := context.Background()
exec := nodeExecutor{}

t.Run("not-yet-started", func(t *testing.T) {
id := "id"
n := &mocks.ExecutableNode{}
n.OnGetID().Return(id)
nl := &mocks4.NodeLookup{}
ns := &mocks.ExecutableNodeStatus{}
ns.OnGetPhase().Return(v1alpha1.NodePhaseNotYetStarted)
nl.OnGetNodeExecutionStatusMatch(mock.Anything, id).Return(ns)
assert.NoError(t, exec.FinalizeHandler(ctx, nil, nil, nl, n))
})
}