Repository navigation
feat(computing-unit): email owner on admin terminate - #9174
Merged
Merged
Conversation
Contributor
Automated Reviewer SuggestionsBased on the
|
Contributor
Author
|
/request-review @aicam |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9174 +/- ##
=========================================
Coverage 91.95% 91.96%
Complexity 5081 5081
=========================================
Files 1280 1281 +1
Lines 55622 55676 +54
Branches 7048 7052 +4
=========================================
+ Hits 51147 51201 +54
Misses 2733 2733
Partials 1742 1742
*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:
|
Codecov reported 8 of the notifier's lines as missed or partial. The real send now takes the sender and password, so a test can drive it with Transport.send mocked statically. A new test pins the skip logs at info and checks they are silent at warn. Email is a plain class and the logger is strict, so neither adds branches no test can reach, and the no-address case is the match's fallback rather than a None case followed by a MatchError branch that can never run.
aicam
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Problem. An admin can terminate any user's computing unit from Admin > Computing Units (#8947), but the owner is not told. The unit just disappears from their workspace, with nothing saying who removed it. Amber's
GmailResourcealready sends mail, but the computing unit managing service cannot depend on amber.Fix. After the terminate transaction commits,
DELETE /computing-unit/{cuid}/terminateemails 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'sEmailTemplate. A newComputingUnitEmailNotifiersends it from the Gmail account amber uses (USER_SYS_GOOGLE_SMTP_GMAILandUSER_SYS_GOOGLE_SMTP_PASSWORD, which the Helm chart and the single-node.envalready 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 thecom.sun.activation2.0.1 already in the dist. The dist also carried Jackson'sjakarta.activation-api2.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, soLICENSE-binaryadds the mail jar and drops that one, andNOTICE-binaryis regenerated.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
GmailResourceis 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 #6483. Part of #6476.
Follows #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.
The first command passes 63 tests and the second passes 316, with 1 canceled: the
run()spec, which needs the Postgres that CI provides.scalafmtCheckAllandscalafixAll --checkran clean. On the built dist,bin/licensing/check_binary_deps.pypasses with and without--ignore-transitive-version,generate_notice_binary.pyreproduces the committedNOTICE-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