kunwp1 opened a new pull request, #8947:
URL: https://github.com/apache/texera/pull/8947

   ### What changes were proposed in this PR?
   
   Problem. An admin can list every computing unit on Admin > Computing Units 
(#8888) but cannot act on one. Freeing a stuck or idle unit on a full 
Kubernetes cluster still means finding its pod and deleting it with `kubectl`. 
The backend already lets an ADMIN terminate any unit (`DELETE 
/computing-unit/{cuid}/terminate`, #7337), so only the UI is missing.
   
   Fix. Adds a delete-icon button to every row, in a new Actions column. It 
calls `ComputingUnitActionsService.confirmAndTerminate`, the confirmation the 
user's own Computing Units page already uses, so the dialog follows the unit 
type: a "results will be lost" warning for a Kubernetes unit and "Disconnect" 
for a local one. Cancelling the dialog or a failed request leaves the row 
alone. `confirmAndTerminate` gains an optional `onTerminated` callback that 
runs only after a successful termination, and the page uses it to drop the row 
at once instead of showing the unit as `Running` until the next 5 second poll.
   
   Two details follow from an admin seeing other users' units. A poll that 
started before the `DELETE` can answer after it with the unit still listed, so 
the page remembers the units it terminated and filters them out of every poll 
response. And ng-zorro renders the dialog and toast text through `[innerHTML]` 
while any user can rename their unit, so `confirmAndTerminate` now HTML-escapes 
the unit name for every caller.
   
   ```
   Before:  admin finds a stuck unit on the page -> finds its pod -> kubectl 
delete pod
   After:   admin finds a stuck unit on the page -> clicks its delete icon -> 
confirms -> row disappears
   ```
   
   Not included. Telling the owner their unit was terminated (#6483) and the 
cluster capacity panels (#6481, #6482) are separate issues. There is no backend 
change.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6480. Part of #6476.
   
   Follows #8888, which added the page.
   
   ### How was this PR tested?
   
   Tests were added for the button, the hand-off to the dialog and the name 
escaping. They cover a button on every row (Kubernetes and local), the click 
confirming the clicked row's unit, the row leaving only after a successful 
termination and staying on cancel or failure, a stale in-flight poll not 
bringing the row back, the detail row's `colspan`, a unit name holding markup 
in the dialog and the toast, and `onTerminated` firing on success only. The 
tests were written first and watched fail, and breaking the code on purpose 
(name left unescaped, callback on every outcome, row dropped on click, poll 
responses left unfiltered) fails exactly the seven tests meant to catch it.
   
   ```
   cd frontend && npx ng test --watch=false 
--include='**/admin-computing-unit.component.spec.ts' 
--include='**/computing-unit-actions.service.spec.ts'
   cd frontend && npx ng test --watch=false
   ```
   
   The first command passes 53 tests and the second passes 6,622 (1 skipped). 
`ngc -p src/tsconfig.app.json --noEmit`, `prettier-eslint` and `eslint` ran 
clean on the changed files.
   
   Checked in a browser against a local stack: sign in as an admin, open Admin 
> Computing Units, and every row has a delete icon whose tooltip reads 
"Disconnect from this computing unit" for a local unit. Clicking it opens the 
confirmation naming that row's unit, and Cancel leaves the table unchanged 
across a full poll. For a throwaway local unit, confirming returned 200 from 
`DELETE /api/computing-unit/12/terminate` and the row left the table 17 ms 
after the response, about 4.8 seconds before the next poll. No Kubernetes 
cluster was available, so the Kubernetes dialog (the red warning and the pod 
deletion) is covered by the existing `confirmAndTerminate` tests and #7337 
only, and so is an admin terminating another user's unit, since the throwaway 
belonged to the admin account.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code, Claude Sonnet 5.5
   


-- 
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]

Reply via email to