The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-6853-ba63cedf0185dc1cd92fd4eec5f175a660639c02
 has failed.
Run started by GitHub user kunwp1 (triggered by kunwp1).

Head commit for run:
cc342ae880bc66d4b49a91bf76a9b357b24c737d / Kunwoo (Chris) 
<[email protected]>
refactor(computing-unit-managing-service): share CU listing helpers and batch 
k8s calls (#6853)

### What changes were proposed in this PR?

Refactor the per-user computing-unit listing so its status/metrics logic
lives in one reusable place and hits Kubernetes in bulk. No API response
changes; this is groundwork for the admin listing endpoint (stacked
follow-up PR).

- Centralize listing logic in `ComputingUnitHelpers`
(`resolveOwnerInfo`, `partitionLiveUnits`,
`reconcileVanishedKubernetesUnits`, `buildDashboardUnit`, plus the
`isKubernetes` / `podPhasesFor` / `podMetricsFor` guards), and remove
the duplicated private status/metrics helpers from
`ComputingUnitManagingResource`.
- 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 probing pod existence twice per unit and re-fetching `top()`
per unit.
- Per-user reconciliation now runs over cuid-deduplicated units,
reducing redundant DB updates.
- Add a package-private `KubernetesClient` test seam
(`setClientForTesting`) so the fabric8 client can be stubbed in tests;
unused in production.

### Any related issues, documentation, discussions?

Part of #6476 (Admin Computing Units Dashboard); prepares the shared
listing helpers reused by the admin endpoint in the stacked follow-up.
Originates from discussion #6322.

### How was this PR tested?

Added `ComputingUnitManagingResourceSpec` and extended
`ComputingUnitHelpersSpec` / `KubernetesClientSpec` (embedded Postgres
via `MockTexeraDB`; stubbed fabric8 client for the bulk k8s paths).

Ran `sbt 'ComputingUnitManagingService/testOnly
org.apache.texera.service.util.ComputingUnitHelpersSpec
org.apache.texera.service.util.KubernetesClientSpec
org.apache.texera.service.resource.ComputingUnitManagingResourceSpec'`
(34 tests, 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

---------

Signed-off-by: Kunwoo (Chris) <[email protected]>
Co-authored-by: Copilot Autofix powered by AI 
<[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/30666390179

With regards,
GitHub Actions via GitBox

Reply via email to