Repository navigation
fix(frontend): reset the run state when its unit is lost - #8936
Conversation
ExecuteWorkflowService resets an in-flight execution (state, worker ids, clock) when the selected unit drops to none, keeping console and results, and the canvas kill button is disabled whenever the websocket is down.
Automated Reviewer SuggestionsBased on the
|
Backport auto-label reportThis
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8936 +/- ##
=========================================
Coverage 91.78% 91.78%
- Complexity 5022 5023 +1
=========================================
Files 1283 1283
Lines 56875 56880 +5
Branches 7442 7445 +3
=========================================
+ Hits 52204 52210 +6
Misses 2800 2800
+ Partials 1871 1870 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/request-review @kunwp1 |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the state-reset and Kill-gating changes.
No open issues 🎉
What changed in this PR
This pull request resets stale frontend execution state when the selected computing unit disappears and prevents unusable Kill actions when the websocket is disconnected.
Changes:
- Reset active execution state, worker assignments, and the run clock when the selected unit is lost.
- Remove the
NoComputingUnitexception from the Kill websocket gate. - Add regression tests for unit loss, execution states, clock behavior, and Kill enablement.
| File | Summary |
|---|---|
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts |
Resets active execution state and workers when the selected computing unit becomes unavailable. |
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.spec.ts |
Tests unit-loss resets across execution states, worker cleanup, clock behavior, and unit transitions. |
frontend/src/app/workspace/component/menu/menu.component.spec.ts |
Tests Kill-button behavior across websocket, unit-selection, and execution-state combinations. |
frontend/src/app/workspace/component/menu/menu.component.html |
Disables Kill when the workflow websocket is disconnected; the gate still needs to include the terminal Terminated state. |
This pull request requires changes.
Review effort: Lite
ExecuteWorkflowService now resets an in-flight execution only when the websocket is down and the selected unit is gone or reports Failed, isExecutionInFlight takes the state and is shared with the canvas lock, and the duplicate spec cases are folded into tables.
What changes were proposed in this PR?
Root cause. The frontend learns that a run has ended only from the engine, over the selected unit's websocket. When the selected unit is terminated from the unit dropdown, drops out of the unit list, or stays selected but reports Failed, as an evicted or crash-looping Kubernetes unit does, that message can never arrive and nothing resets the execution state, so the run keeps being reported as running. On top of that, the Kill button's gate exempted
NoComputingUnitfrom its socket check, so Kill stayed enabled although its request could no longer be delivered. #3400 (a910bcf) added the socket check to Kill together with that exemption, copying the Run button's translation of the old single-mode flag!environment.computingUnitManagerEnabled; that mode no longer exists.Both screenshots: a run was in flight on "Analytics Unit", which was then terminated from the unit dropdown.
Form View after the same steps no longer reports a run:
Changes.
ExecuteWorkflowServicecalls its existingresetExecutionAndWorkers()when an execution is in flight, the workflow websocket is down, and the selected unit is either gone or reports Failed. It combines the selected-unit stream with the websocket's connection-status stream, so the reset fires on whichever of the two happens last. That puts the execution back to Uninitialized, which Form View and the canvas lock already follow, clears the worker ids and stops the clock. It is the narrower of the two existing resets: console messages and results stay, unlike theconnectionResetpath a manual unit switch takes.NoComputingUnitexemption. This is defense in depth: with change 1, a run that is still in flight with no unit and no socket should not occur any more, and if it does, Kill no longer looks usable.isExecutionInFlighttakes the state andupdateWorkflowActionLockcalls it, so the reset and the canvas lock share one list of in-flight states.What does and does not trigger the reset in change 1:
connectionResetpath handles the switchScope boundary. The canvas can be locked again right away by a second, independent check, which this PR leaves unchanged. Whenever the selected unit changes, including when it drops to none,
ComputingUnitSelectionComponent.updateWorkflowModificationStatusasks the database for Running or Initializing executions of the workflow. If it finds any, it disables modification and shows "There are ongoing executions on this workflow. Modification of the workflow is currently disabled." At that moment the lost unit's execution row is still RUNNING, because disconnecting a local unit does not stop the shared engine, which keeps running the execution. The lock is accurate, and the check passes again on the first reload or unit selection after that execution finishes.Also not changed here: on a dropdown terminate, the existing
clearStatus()call inComputingUnitStatusService.terminateComputingUnitresets the operators' colors, while their port row counts keep the last values. When the unit is lost any other way, for example an evicted unit that reports Failed or a terminate from another tab, nothing resets the colors, so the operators keep their last state after the reset.Not covered: a unit that is lost without reporting Failed or leaving this tab's unit list. A unit whose pod state cannot be determined reports Unknown, and a pod deleted outside Texera is polled as Pending until this tab next refreshes its unit list; in both the run keeps showing as running.
Any related issues, documentation, discussions?
Closes #8934
Related:
isConnectedbeing accurate.How was this PR tested?
New tests in
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.spec.ts:New tests in
frontend/src/app/workspace/component/menu/menu.component.spec.ts, one table for the Kill button:The shared
beforeEachof the service spec now installs aBehaviorSubjectfor the selected-unit stream and one for the connection-status stream before the service is constructed, since the service subscribes in its constructor. Form View needs no test of its own: it readsisRunningfrom the execution state stream thatresetExecutionAndWorkers()already broadcasts.ExecuteWorkflowServicedoes not inject the console or result services, so this change cannot clear them.Mutation check: each of these makes at least one test fail: restoring the
NoComputingUnitexemption, dropping the socket condition, dropping the Failed condition, dropping the empty-selection condition, resetting regardless of the execution state, resetting on any non-Running unit status, reading the socket state only when the selection changes, reading the selection only when the socket state changes, usingresetExecutionState()instead ofresetExecutionAndWorkers(), a reset that forgets to clear the worker ids, letting only the first lost unit reset, moving any one of the eleven states across the in-flight split, and swapping the enable and disable branches of the canvas lock.Manual check in Chrome, 1512x861 viewport, against a build of this branch on the local-dev stack with local computing units:
process_tupledoestime.sleep(900).After: the execution is back to Uninitialized, the clock reads 0:00:00, Kill is disabled, and Form View no longer reports a run; console and results stay. The canvas is locked again right away with the info message quoted under "Scope boundary", because the shared local engine is still running the execution.
Was this PR authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Code (claude-fable-5-1, claude-fable-5-2, claude-opus-5-5). Co-authored with Claude; the author reviewed the change before submission.