fix: route local dag-run stop correctly#1993
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/service/frontend/api/v1/dagruns.go (1)
2207-2254: Routing logic change looks correct for the PR objective.The switch from
WorkerID != ""toShouldDispatchToCoordinator(dag, ...)correctly determines the stop path based on DAG definition properties (ForceLocal,WorkerSelector) and execution mode rather than a potentially staleWorkerIDin saved status.However, lines 2222-2227 contain dead code:
if a.coordinatorCli == nil { return nil, &Error{ HTTPStatus: http.StatusServiceUnavailable, Code: api.ErrorCodeInternalError, Message: "coordinator not configured for distributed DAG cancellation", } }Per the
ShouldDispatchToCoordinatorimplementation (context snippet 1, lines 11-13), the function returnsfalsewhen!hasCoordinator. Since you passa.coordinatorCli != nilashasCoordinator, ifShouldDispatchToCoordinatorreturnstrue, thena.coordinatorCliis guaranteed non-nil. This nil check can never be true.🔧 Optional: Remove dead code
if core.ShouldDispatchToCoordinator(dag, a.coordinatorCli != nil, a.defaultExecMode) { // For distributed DAGs, use saved status for running check if savedStatus.Status != core.Running { return nil, &Error{ HTTPStatus: http.StatusBadRequest, Code: api.ErrorCodeNotRunning, Message: "DAG is not running", } } - // Send cancel request via coordinator - if a.coordinatorCli == nil { - return nil, &Error{ - HTTPStatus: http.StatusServiceUnavailable, - Code: api.ErrorCodeInternalError, - Message: "coordinator not configured for distributed DAG cancellation", - } - } if err := a.coordinatorCli.RequestCancel(ctx, request.Name, request.DagRunId, nil); err != nil { return nil, fmt.Errorf("error requesting cancel: %w", err) } } else {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/service/frontend/api/v1/dagruns.go` around lines 2207 - 2254, The nil-check block that returns ServiceUnavailable is dead code because ShouldDispatchToCoordinator(dag, a.coordinatorCli != nil, a.defaultExecMode) guarantees a.coordinatorCli is non-nil when it returns true; remove the if a.coordinatorCli == nil { ... } block (the ServiceUnavailable Error return) from the coordinator branch so the code proceeds directly to calling a.coordinatorCli.RequestCancel(ctx, request.Name, request.DagRunId, nil) (keep RequestCancel error handling as-is).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/service/frontend/api/v1/dagruns.go`:
- Around line 2207-2254: The nil-check block that returns ServiceUnavailable is
dead code because ShouldDispatchToCoordinator(dag, a.coordinatorCli != nil,
a.defaultExecMode) guarantees a.coordinatorCli is non-nil when it returns true;
remove the if a.coordinatorCli == nil { ... } block (the ServiceUnavailable
Error return) from the coordinator branch so the code proceeds directly to
calling a.coordinatorCli.RequestCancel(ctx, request.Name, request.DagRunId, nil)
(keep RequestCancel error handling as-is).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ebe14d74-56a7-45c1-ae2a-c48113614a87
📒 Files selected for processing (1)
internal/service/frontend/api/v1/dagruns.go
Summary
Why
A local DAG run could still have a non-empty
WorkerIDin its saved status. The stop endpoint used that field as the distributed/local switch, which made local stop requests attempt coordinator cancellation and fail with500 error requesting cancel: no coordinators available.Test plan
go test ./internal/service/frontend/api/v1 -count=1Summary by CodeRabbit
Release Notes