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

   ### What changes were proposed in this PR?
   
   Adds an ADMIN-only endpoint that returns every non-terminated computing unit 
across all users, backing the planned admin Computing Units dashboard 
(cross-user monitoring and reclaim). A new `AdminComputingUnitResource` — with 
a class-level `@RolesAllowed(Array("ADMIN"))`, mirroring 
`AdminExecutionResource` — exposes `GET /computing-unit/admin/list` and returns 
`List[DashboardWorkflowComputingUnit]`, the same shape the existing per-user 
`listComputingUnits` produces.
   
   The endpoint queries all units via `WorkflowComputingUnitDao`, excludes rows 
with a non-null `terminate_time`, joins `UserDao` for each owner's name and 
avatar, and reuses `ComputingUnitHelpers.getComputingUnitStatus` / 
`getComputingUnitMetrics` for status and metrics. The row-assembly logic is 
extracted into a pure `buildDashboardUnits` function so it can be unit-tested 
without a database or Kubernetes.
   
   The new resource is registered in `ComputingUnitManagingService`, and the 
service's startup access-control coverage check is extended to include it.
   
   Two field choices worth noting for reviewers: `accessPrivilege` is reported 
as `WRITE` for admin rows (an admin can manage any unit it can see), and 
`isOwner` reflects whether the requesting admin happens to own the unit.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6477. Part of #6476 (Admin Computing Units Dashboard). Originates 
from discussion #6322.
   
   ### How was this PR tested?
   
   Added `AdminComputingUnitResourceSpec` with two cases: the resource permits 
only the `ADMIN` role (the `@RolesAllowed(Array("ADMIN"))` contract that makes 
Jersey reject non-admin callers with 403), and `buildDashboardUnits` returns 
active units owned by multiple users while excluding terminated ones, with 
owner name and avatar mapped correctly. `ComputingUnitManagingServiceRunSpec` 
was extended to assert the new resource declares access control.
   
   Ran `sbt 'ComputingUnitManagingService/testOnly 
org.apache.texera.service.resource.AdminComputingUnitResourceSpec 
org.apache.texera.service.ComputingUnitManagingServiceRunSpec'` (all green) and 
`sbt 'ComputingUnitManagingService/scalafmtCheck; 
ComputingUnitManagingService/Test/scalafmtCheck'` (clean). I did not exercise 
the endpoint end-to-end against a live database and admin JWT; the 
database/Kubernetes paths are thin DAO glue, and the extracted 
`buildDashboardUnits` covers the row-selection and owner-mapping behavior under 
test.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code, Claude Opus 4.8
   


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