-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] correctly set task execution phase for terminal array node #5136
Conversation
Signed-off-by: Paul Dittamo <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5136 +/- ##
=======================================
Coverage 37.02% 37.02%
=======================================
Files 1317 1317
Lines 132523 132544 +21
=======================================
+ Hits 49066 49080 +14
- Misses 79211 79218 +7
Partials 4246 4246
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Paul Dittamo <[email protected]>
Signed-off-by: Paul Dittamo <[email protected]>
Signed-off-by: Paul Dittamo <[email protected]>
Code Review Agent Run #e4c107Actionable Suggestions - 2
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
if !eventsErr.IsAlreadyExists(err) { | ||
logger.Errorf(ctx, "ArrayNode event recording failed: [%s]", err.Error()) | ||
return err |
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.
Consider handling the error case more gracefully by logging the error and continuing execution rather than returning early. The current implementation may cause unnecessary aborts.
Code suggestion
Check the AI-generated fix before applying
if !eventsErr.IsAlreadyExists(err) { | |
logger.Errorf(ctx, "ArrayNode event recording failed: [%s]", err.Error()) | |
return err | |
if eventsErr.IsAlreadyExists(err) { | |
return nil | |
} |
Code Review Run #e4c107
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
// ensure task_execution set to failed - this should already be sent by the abort handler | ||
if err := eventRecorder.finalize(ctx, nCtx, idlcore.TaskExecution_FAILED, 0, a.eventConfig); err != nil { |
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.
Consider checking if eventRecorder
is not nil before calling finalize()
. The current code assumes eventRecorder
is always initialized.
Code suggestion
Check the AI-generated fix before applying
// ensure task_execution set to failed - this should already be sent by the abort handler | |
if err := eventRecorder.finalize(ctx, nCtx, idlcore.TaskExecution_FAILED, 0, a.eventConfig); err != nil { | |
// ensure task_execution set to failed - this should already be sent by the abort handler | |
if eventRecorder == nil { | |
logger.Errorf(ctx, "ArrayNode eventRecorder is nil") | |
return handler.UnknownTransition, fmt.Errorf("eventRecorder is nil") | |
} | |
if err := eventRecorder.finalize(ctx, nCtx, idlcore.TaskExecution_FAILED, 0, a.eventConfig); err != nil { |
Code Review Run #e4c107
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
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.
Any unit tests we should be adding? It looks like we will send some new events now right?
@hamersaw I'll upstream unit tests for array node and then add tests in this PR |
Signed-off-by: Paul Dittamo <[email protected]>
Code Review Agent Run #5e4929Actionable Suggestions - 2
Review Details
|
subNodePhases: []v1alpha1.NodePhase{v1alpha1.NodePhaseSucceeded, v1alpha1.NodePhaseRunning, v1alpha1.NodePhaseNotYetStarted}, | ||
subNodeTaskPhases: []core.Phase{core.PhaseSuccess, core.PhaseRunning, core.PhaseUndefined}, |
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.
Consider using constants or enums for the node phases and task phases arrays to improve readability and maintainability. The array literals []v1alpha1.NodePhase{...}
and []core.Phase{...}
could be defined as test constants.
Code suggestion
Check the AI-generated fix before applying
@@ -203,6 +203,16 @@ func TestAbort(t *testing.T) {
+var (
+ testSubNodePhases = []v1alpha1.NodePhase{v1alpha1.NodePhaseSucceeded, v1alpha1.NodePhaseRunning, v1alpha1.NodePhaseNotYetStarted}
+ testSubNodeTaskPhases = []core.Phase{core.PhaseSuccess, core.PhaseRunning, core.PhaseUndefined}
+)
@@ -220,8 +220,8 @@ func TestAbort(t *testing.T) {
- subNodePhases: []v1alpha1.NodePhase{v1alpha1.NodePhaseSucceeded, v1alpha1.NodePhaseRunning, v1alpha1.NodePhaseNotYetStarted},
- subNodeTaskPhases: []core.Phase{core.PhaseSuccess, core.PhaseRunning, core.PhaseUndefined},
+ subNodePhases: testSubNodePhases,
+ subNodeTaskPhases: testSubNodeTaskPhases,
Code Review Run #5e4929
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -279,12 +295,13 @@ func TestAbort(t *testing.T) { | |||
nCtx := createNodeExecutionContext(dataStore, eventRecorder, nil, literalMap, &arrayNodeSpec, arrayNodeState, 0, workflowMaxParallelism) | |||
|
|||
// evaluate node | |||
err := arrayNodeHandler.Abort(ctx, nCtx, "foo") | |||
err = arrayNodeHandler.Abort(ctx, nCtx, "foo") |
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.
Consider declaring err
variable before using it. The current code reuses an existing err
variable which could lead to shadowing issues.
Code suggestion
Check the AI-generated fix before applying
err = arrayNodeHandler.Abort(ctx, nCtx, "foo") | |
err := arrayNodeHandler.Abort(ctx, nCtx, "foo") |
Code Review Run #5e4929
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@hamersaw ended up not needing to upstream tests |
Tracking issue
#5135
Why are the changes needed?
Task execution phases are not set correctly for successful nor failed ArrayNodes
What changes were proposed in this pull request?
How was this patch tested?
Setup process
ran a workflow with a map task that failed and one that succeeded. Confirmed that the taskExecution closure phase was correctly set.
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR addresses a bug in the array node handler related to task execution phase settings. The changes implement proper phase setting in task execution events and streamline the abort handler by removing redundant failure event recording. The modifications enhance state reporting accuracy for both successful and failed terminal states, while improving test coverage for phase transitions. The update includes comprehensive test cases for verifying task execution phases across different array node states.Unit tests added: True
Estimated effort to review (1-5, lower is better): 2