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

   ### What changes were proposed in this PR?
   
   Problem. When a computing unit stays `Pending` on a full cluster, Admin > 
Computing Units (#8888) lists the unit but not how much of the cluster is left, 
so an admin still runs `kubectl describe nodes` to find which resource ran out. 
The backend has reported it since #8986 (`GET 
/computing-unit/admin/cluster-capacity`), but nothing in the UI reads it.
   
   Fix. Adds a Cluster capacity card above the units table. CPU, memory and GPU 
each get a row with a bar of the share allocated, then the allocated, available 
and total amounts: CPU in cores to the millicore, memory in binary units 
(`GiB`, as unit limits are written) and GPU as a count. The bars share one 
scale, so the resource that runs out first stands out. From 80% a row turns 
gold and is marked "Running low", and from 95% red and "Nearly full", with an 
icon and a screen-reader label so color is not the only signal. The share is 
rounded down, so 100% shows only when nothing is left, and it can pass 100% 
(the bar cannot) when pods request more than the nodes offer. A note under the 
rows says that allocated means requested, not used, and that available is 
summed across nodes.
   
   The card polls every 30 seconds rather than the table's 5, since capacity 
only moves when units start or stop and the backend lists every pod in the 
cluster to answer. A refresh button fetches at once and restarts the 30 
seconds, so a click is not followed by a second cluster-wide listing seconds 
later. On a deployment without Kubernetes units the endpoint answers 404, so 
the card never shows and the poll ends. Any other failure shows the cluster's 
own message (a missing read grant reads "nodes is forbidden: ..."), and a 
failed refresh keeps the last numbers under a warning, as the table does. A 
resource the cluster has none of, usually GPU, reads "None in the cluster", and 
a missing, non-numeric or negative figure reads "Not reported" without taking 
the other rows down. When the card is narrower than the table needs, which the 
sidebar decides rather than the window, the rows stack into one labelled line 
per figure.
   
   ```
   Before:  admin sees a unit stuck Pending -> kubectl describe nodes -> adds 
up the requests by hand
   After:   admin sees a unit stuck Pending -> Admin > Computing Units -> CPU 
82% Running low, GPU 100% Nearly full
   ```
   
   Not included. Telling the owner when an admin terminates their unit (#6483). 
The card shows what the endpoint reports, so the endpoint's limits carry over: 
`available` is an upper bound summed across nodes, so free capacity spread over 
several nodes can still refuse a unit that needs one node's worth, and a 
tainted node (say an RKE2 server reserved for control-plane pods) still counts 
although no unit can be scheduled there. Like the units table, the card keeps 
polling while the browser tab is hidden.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6482. Part of #6476.
   
   Reads the endpoint added in #8986, on the page added in #8888.
   
   ### How was this PR tested?
   
   Tests were added for the service call, the card and its place on the page. 
They cover the units (cores to the millicore, "1 core" in the singular, grouped 
thousands, MiB to TiB, moving up a unit when rounding reaches 1,024), rounding 
down (99% for 15.99 of 16 cores, and 29 of 100 not flooring to 28% through 
float error), a share over 100% with the bar capped, the 80% and 95% flags, a 
total of zero, a missing, non-numeric or negative figure, nothing rendered 
before the first answer, the 404 hiding the card and ending the poll, the 
first-load error, an empty error message, the stale warning and its recovery, 
the 30 s cadence, a refresh click restarting it, and a click ignored while a 
fetch is in flight. The tests were written first and watched fail on a stub, 
and breaking the code on purpose (the share rounded instead of floored, the bar 
left uncapped, a 404 treated as an ordinary error, the flags moved past 80% and 
95%, negative figures accepted, the clock not restarted on refresh,
  clicks not dropped while a fetch is in flight, the memory unit chosen before 
rounding, an empty message left empty) turns a test red each time.
   
   ```
   cd frontend && npx ng test --watch=false 
--include='**/admin-cluster-capacity.component.spec.ts' 
--include='**/admin-computing-unit.component.spec.ts' 
--include='**/workflow-computing-unit-managing.service.spec.ts'
   cd frontend && npx ng test --watch=false
   ```
   
   The first command passes 71 tests and the second passes 6,849 (1 skipped). 
`ngc -p src/tsconfig.app.json --noEmit`, `prettier-eslint` and `eslint` ran 
clean on the changed files.
   
   Checked in Chrome against a mock of the endpoint, since the local stack has 
no Kubernetes cluster: open Admin > Computing Units as an admin at 1440, 768, 
640 and 375 px wide, with CPU running low, memory normal and GPU full, a 
cluster without GPUs, a first load that fails, a refresh that fails after a 
good load, and a 404, where the page renders as before. Not exercised: a live 
cluster, or the real endpoint over HTTP.
   
   | Before | After |
   | --- | --- |
   | (drop before-1440.png here) | (drop after-1440.png here) |
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code, Claude Opus 5.5
   


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