Skip to content

feat(frontend): add admin computing unit terminate button - #8947

Merged
kunwp1 merged 1 commit into
apache:mainfrom
kunwp1:feat/admin-cu-terminate-button
Oct 12, 2026
Merged

kunwp1 merged 1 commit into
apache:mainfrom
kunwp1:feat/admin-cu-terminate-button

Conversation

@kunwp1

@kunwp1 kunwp1 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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.

Screen.Recording.2026-10-10.at.4.30.51.PM.mov

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code, Claude Sonnet 5.5

@github-actions github-actions Bot added feature frontend Changes related to the frontend GUI labels Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @tanishqgandhi1908
    You can notify them by mentioning @tanishqgandhi1908 in a comment.

@kunwp1

kunwp1 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

/request-review @aicam

@github-actions

Copy link
Copy Markdown
Contributor

Please specify at least one reviewer: /request-review @user.
Check the suggestion comment on this PR for candidates.

@kunwp1
kunwp1 requested a review from aicam October 10, 2026 23:43
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.61%. Comparing base (53114a7) to head (8453cae).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8947   +/-   ##
=========================================
  Coverage     92.61%   92.61%           
  Complexity     5060     5060           
=========================================
  Files          1257     1257           
  Lines         53762    53783   +21     
  Branches       6705     6705           
=========================================
+ Hits          49789    49809   +20     
  Misses         2316     2316           
- Partials       1657     1658    +1     
Flag Coverage Δ *Carryforward flag
access-control-service 77.38% <ø> (ø) Carriedforward from 53114a7
agent-service 99.16% <ø> (ø) Carriedforward from 53114a7
amber 88.10% <ø> (ø) Carriedforward from 53114a7
computing-unit-managing-service 60.48% <ø> (ø) Carriedforward from 53114a7
config-service 87.37% <ø> (ø) Carriedforward from 53114a7
file-service 81.95% <ø> (ø) Carriedforward from 53114a7
frontend 96.58% <100.00%> (-0.01%) ⬇️
notebook-migration-service 83.73% <ø> (ø) Carriedforward from 53114a7
pyamber 98.52% <ø> (ø) Carriedforward from 53114a7
workflow-compiling-service 74.09% <ø> (ø) Carriedforward from 53114a7

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kunwp1
kunwp1 added this pull request to the merge queue Oct 12, 2026
Merged via the queue into apache:main with commit d27b7b4 Oct 12, 2026
32 checks passed
@kunwp1
kunwp1 deleted the feat/admin-cu-terminate-button branch October 12, 2026 03:46
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Oct 27, 2026
### What changes were proposed in this PR?

Problem. An admin can terminate any user's computing unit from Admin >
Computing Units (apache#8947), but the owner is not told. The unit just
disappears from their workspace, with nothing saying who removed it.
Amber's `GmailResource` already sends mail, but the computing unit
managing service cannot depend on amber.

Fix. After the terminate transaction commits, `DELETE
/computing-unit/{cuid}/terminate` emails the unit's owner when the
caller is someone else, which only an ADMIN can be, and the unit was
still running. The email names the unit, its ID and the UTC time it was
terminated, and asks the owner to contact the administrator, with the
subject suffix and "Sent from" footer of amber's `EmailTemplate`. A new
`ComputingUnitEmailNotifier` sends it from the Gmail account amber uses
(`USER_SYS_GOOGLE_SMTP_GMAIL` and `USER_SYS_GOOGLE_SMTP_PASSWORD`, which
the Helm chart and the single-node `.env` already pass to this service)
on one background thread, so the terminate response never waits on SMTP.
Without a sender or an owner address it sends nothing, and a failed send
only logs, since the unit is already gone. The connection checks the
server's certificate identity and times out after 10 seconds.

The service gains one jar, `com.sun.mail:jakarta.mail:2.0.2` (EPL-2.0 or
GPL-2.0 with Classpath Exception), which runs on the
`com.sun.activation` 2.0.1 already in the dist. The dist also carried
Jackson's `jakarta.activation-api` 2.1.0, which ships the same package
without a provider, so if it loaded first, building a message failed
with "Provider for jakarta.activation.spi.MailcapRegistryProvider cannot
be found". The module now excludes it, so `LICENSE-binary` adds the mail
jar and drops that one, and `NOTICE-binary` is regenerated.

```
Before:  admin terminates Ada's unit -> it vanishes from Ada's workspace, nothing says why
After:   admin terminates Ada's unit -> Ada gets an email naming the unit and when it was terminated
```

Not included. The email has fixed text: the dialog does not ask the
admin for a reason, and the email does not name the admin. A unit
terminated by its owner or by the idle cleanup job sends nothing.
Amber's `GmailResource` is not changed or shared. Terminate still
re-stamps a unit that is already terminated, as before, and only the
email is gated, so two admins terminating the same unit at the same
moment could each send one. An email still queued when the service stops
is lost.

### Any related issues, documentation, discussions?

Closes apache#6483. Part of apache#6476.

Follows apache#8947, which added the terminate button to the admin page.

### How was this PR tested?

Tests were added for the notifier and the endpoint. The notifier's cover
the message (unit name, ID and UTC time, a missing or blank owner name,
the deployment in the subject and footer or neither), a non-ASCII name
surviving into the 7-bit wire form, a malformed recipient, the SMTP
settings, and the skips and failures: no sender, an owner with no
address or a blank one, a send that throws, and the send running on the
executor rather than the caller's thread. The endpoint's cover who is
notified: the owner when an admin terminates their unit, only after the
commit (checked from a second connection), and nobody when the caller
owns the unit, admin or not, when a non-owner is refused, when the unit
does not exist, or when its owner already terminated it. A 200 still
comes back when notifying throws. The tests were written first and
failed to compile against the unchanged resource. Breaking the code on
purpose (notifying on every terminate, the owner check inverted,
notifying inside the transaction, notifying again for an
already-terminated unit, ignoring a missing sender, sending on the
caller's thread, either catch removed, the address not trimmed, the
server-identity check off, a blank name greeted) turns at least one test
red each time.

```
sbt "ComputingUnitManagingService/testOnly org.apache.texera.service.util.ComputingUnitEmailNotifierSpec org.apache.texera.service.resource.ComputingUnitManagingResourceSpec"
sbt "ComputingUnitManagingService/test"
```

The first command passes 63 tests and the second passes 316, with 1
canceled: the `run()` spec, which needs the Postgres that CI provides.
`scalafmtCheckAll` and `scalafixAll --check` ran clean. On the built
dist, `bin/licensing/check_binary_deps.py` passes with and without
`--ignore-transitive-version`, `generate_notice_binary.py` reproduces
the committed `NOTICE-binary`, and a message builds and serializes on
the dist's own classpath. Not exercised: a real send, since there are no
Gmail credentials locally, so the login to smtp.gmail.com is untested,
and a Kubernetes unit, since the local stack has no cluster.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code, Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin CUs: terminate with confirmation

3 participants