kunwp1 commented on code in PR #8936:
URL: https://github.com/apache/texera/pull/8936#discussion_r4509304366
##########
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts:
##########
@@ -140,6 +140,13 @@ export class ExecuteWorkflowService {
}
}
});
+
+ // Ends an in-flight run when the selected unit is gone; console and
results are kept.
+ computingUnitStatusService.getSelectedComputingUnit().subscribe(unit => {
+ if (unit === null && this.isExecutionInFlight()) {
Review Comment:
An eviction doesn't make the unit drop out of the list.
`kubernetesStatusAndReason` maps an evicted pod to Failed ("evicted by the
cluster... Consider recreating it"), and `reconcileVanishedKubernetesUnits`
only retires units whose pods are gone. Crash-looping and OOM-looping units
report Failed the same way. The selection stays non-null, so a run on such a
unit keeps showing as Running with the clock counting, which is the eviction
case the description mentions. In every Failed case the engine that ran the
execution is gone, so treating `status === "Failed"` like an empty selection
would cover it. That would flip the "keeps the run when the selected unit
reports Failed" case.
##########
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts:
##########
@@ -487,6 +494,26 @@ export class ExecuteWorkflowService {
this.anchorDuration(0, false);
}
+ private isExecutionInFlight(): boolean {
+ switch (this.currentState.state) {
Review Comment:
This repeats the six-versus-five split in `updateWorkflowActionLock` below.
If this helper takes the state and the lock calls it, there is one list to keep
in step, and a new state can't lock the canvas while skipping the reset.
##########
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.ts:
##########
@@ -140,6 +140,13 @@ export class ExecuteWorkflowService {
}
}
});
+
+ // Ends an in-flight run when the selected unit is gone; console and
results are kept.
+ computingUnitStatusService.getSelectedComputingUnit().subscribe(unit => {
+ if (unit === null && this.isExecutionInFlight()) {
+ this.resetExecutionAndWorkers();
+ }
+ });
Review Comment:
#8855 merged on Oct 27, so the reason given for not also requiring the
socket to be down no longer applies. Requiring both would remove the side
effect the description lists, where another tab disconnecting a local unit
resets a run this tab can still kill over its open socket. It needs both
streams, for example `combineLatest` with `getConnectionStatusStream()`. The
list can drop the unit before the socket closes, so checking `isConnected` only
when the selection changes would miss that order.
##########
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.spec.ts:
##########
@@ -238,6 +245,171 @@ describe("ExecuteWorkflowService", () => {
});
});
+ describe("losing the selected computing unit mid-run", () => {
+ const unit = (cuid: number): DashboardWorkflowComputingUnit =>
+ ({ computingUnit: { cuid }, status: "Running" }) as unknown as
DashboardWorkflowComputingUnit;
+
+ it("ends a running execution when the selection empties", () => {
+ const enable = vi.spyOn(service["workflowActionService"],
"enableWorkflowModification");
+ const seen: ExecutionState[] = [];
+ service.getExecutionStateStream().subscribe(({ current }) =>
seen.push(current.state));
+ emitWsEvent({ type: "WorkflowStateEvent", state: ExecutionState.Running
});
+ emitWsEvent({ type: "WorkerAssignmentUpdateEvent", operatorId: "op1",
workerIds: ["w1", "w2"] });
+ selectedUnit$.next(unit(7));
+ enable.mockClear();
+
+ selectedUnit$.next(null);
+
+
expect(service.getExecutionState().state).toBe(ExecutionState.Uninitialized);
+ expect(service.getWorkerIds("op1")).toEqual([]);
+ expect(enable).toHaveBeenCalled();
+ expect(seen).toEqual([ExecutionState.Running,
ExecutionState.Uninitialized]);
+ });
+
+ it("ends a paused execution when the selection empties", () => {
+ emitWsEvent({ type: "WorkflowStateEvent", state: ExecutionState.Running
});
+ emitWsEvent({ type: "WorkflowStateEvent", state: ExecutionState.Paused
});
+ selectedUnit$.next(unit(7));
+
+ selectedUnit$.next(null);
+
+
expect(service.getExecutionState().state).toBe(ExecutionState.Uninitialized);
+ });
Review Comment:
Several new cases repeat others in this block:
- This one is the Paused row of the in-flight table.
- "leaves a finished execution alone", "does nothing when no execution has
started" and "keeps the error messages of a failed run" are rows of the
not-in-flight table, whose `toBe(before)` already shows the state, errors
included, is untouched.
- "stops the clock" repeats the existing clock test for
`resetExecutionAndWorkers()`.
The switch, first-selection and four-status cases could be one table, and
the four Kill tests in the menu spec could join the `it.each` there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]