Skip to content

feat(computing-unit-managing-service): add admin endpoint to list all computing units#6484

Draft
kunwp1 wants to merge 2 commits into
apache:mainfrom
kunwp1:feat/admin-list-computing-units
Draft

feat(computing-unit-managing-service): add admin endpoint to list all computing units#6484
kunwp1 wants to merge 2 commits into
apache:mainfrom
kunwp1:feat/admin-list-computing-units

Conversation

@kunwp1

@kunwp1 kunwp1 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds an ADMIN-only endpoint that returns every non-terminated computing unit across all users. Needed for adding admin Computing Units dashboard.

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 new resource is registered in ComputingUnitManagingService.

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

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

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

Generated-by: Claude Code, Claude Opus 4.8

… computing units

Add an ADMIN-only GET /computing-unit/admin/list that returns every
non-terminated computing unit across all users, backing the admin
Computing Units dashboard. Row assembly is extracted into a pure
buildDashboardUnits function so it is unit-testable without a database
or Kubernetes. Register the resource and extend the service's startup
access-control coverage check.
@github-actions github-actions Bot added feature platform Non-amber Scala service paths labels Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

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: @Ma77Ball, @aglinxinyuan, @aicam
    You can notify them by mentioning @Ma77Ball, @aglinxinyuan, @aicam in a comment.

@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.09877% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.85%. Comparing base (e029e0d) to head (cb566cd).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
...che/texera/service/util/ComputingUnitHelpers.scala 57.14% 13 Missing and 5 partials ⚠️
.../service/resource/AdminComputingUnitResource.scala 10.52% 17 Missing ⚠️
.../apache/texera/service/util/KubernetesClient.scala 0.00% 16 Missing ⚠️
...rvice/resource/ComputingUnitManagingResource.scala 0.00% 3 Missing ⚠️
.../texera/service/ComputingUnitManagingService.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6484      +/-   ##
============================================
+ Coverage     69.77%   69.85%   +0.07%     
- Complexity     3379     3401      +22     
============================================
  Files          1142     1143       +1     
  Lines         44828    44889      +61     
  Branches       4948     4957       +9     
============================================
+ Hits          31277    31355      +78     
+ Misses        11895    11868      -27     
- Partials       1656     1666      +10     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø)
agent-service 76.76% <ø> (ø) Carriedforward from 885b3fe
amber 66.56% <ø> (ø) Carriedforward from 885b3fe
computing-unit-managing-service 23.26% <32.09%> (+13.28%) ⬆️
config-service 52.30% <ø> (ø)
file-service 66.80% <ø> (+2.82%) ⬆️
frontend 68.12% <ø> (ø) Carriedforward from 885b3fe
notebook-migration-service 78.94% <ø> (ø)
pyamber 91.13% <ø> (ø) Carriedforward from 885b3fe
workflow-compiling-service 55.14% <ø> (ø)

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

…nd batch k8s calls

Centralize computing-unit listing logic in ComputingUnitHelpers so the
per-user and admin listing endpoints share one implementation:

- Add resolveOwnerInfo, partitionLiveUnits, reconcileVanishedKubernetesUnits,
  and buildDashboardUnit; both listing endpoints now route through them.
- Remove the byte-identical private getComputingUnitStatus/getComputingUnitMetrics
  from ComputingUnitManagingResource; single-unit callers use the shared helpers.
- Add bulk KubernetesClient.getAllPodPhases / getAllPodMetrics (one namespace-wide
  list()/top() each) and a shared containerUsage helper; listComputingUnits now
  resolves pod status/metrics in bulk instead of per-unit (previously podExists was
  probed twice per unit and top() was re-fetched per unit).
- Admin endpoint filters active units in SQL and reconciles vanished pods via the
  shared helper.

Behavior of the API responses is unchanged; per-user reconciliation now runs over
cuid-deduplicated units, reducing redundant DB updates without adding new ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin CUs: backend endpoint to list all computing units

2 participants