Repository navigation
feat(computing-unit): add admin cluster capacity endpoint - #8986
Merged
Merged
Conversation
Contributor
Author
|
/request-review @aicam |
Contributor
Automated Reviewer SuggestionsBased on the
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8986 +/- ##
============================================
- Coverage 92.62% 92.62% -0.01%
- Complexity 5060 5062 +2
============================================
Files 1258 1259 +1
Lines 53791 53836 +45
Branches 6707 6709 +2
============================================
+ Hits 49824 49864 +40
- Misses 2313 2316 +3
- Partials 1654 1656 +2
*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:
|
aicam
reviewed
Oct 24, 2026
…y RBAC names ClusterRole and ClusterRoleBinding names are cluster-wide, but Helm release names are only unique per namespace, so two same-name releases in different namespaces rendered the same names and the second install failed.
kunwp1
enabled auto-merge
October 25, 2026 07:20
renovate-bot
pushed a commit
to renovate-bot/apache-_-texera
that referenced
this pull request
Oct 26, 2026
### What changes were proposed in this PR? Problem. When a computing unit stays `Pending` on a full cluster, Admin > Computing Units (apache#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 apache#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 (apache#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 apache#6482. Part of apache#6476. Reads the endpoint added in apache#8986, on the page added in apache#8888. ### How was this PR tested? Before <img width="2880" height="1800" alt="before-1440" src="https://github.com/user-attachments/assets/4fadf670-2470-4ac7-a028-b4f5f37f27db" /> After <img width="2880" height="1800" alt="after-1440" src="https://github.com/user-attachments/assets/e8240430-e366-440d-8c3e-066ded7276b8" /> ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code, Claude Opus 5.5
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. When a computing unit fails to start because the cluster is full, an admin cannot see from the app how much of the cluster is left (#6476), and the cluster capacity panel (#6482) has nothing to show. The backend only lists pods in the computing-unit pool namespace and never reads node capacity.
Fix. Adds
GET /api/computing-unit/admin/cluster-capacity(ADMIN only), which returnstotal,allocatedandavailablefor CPU (millicores), memory (bytes) and GPU (devices).totalis the allocatable of every Ready, uncordoned node, andallocatedis the requests of the pods running on them in every namespace, with init containers and runtime-class overhead counted the way kube-scheduler counts them. That is the figurekubectl describe nodereports as "Allocated resources", soavailablebounds what a new unit can claim. Live usage from metrics-server is not used because it reads below what is committed and has no GPU metric. The pod list is narrowed on the API server to pods that have not finished, so a cluster that keeps many finished pods does not ship them all. On a deployment without Kubernetes computing units it answers 404, and a Kubernetes API failure comes back with the cluster's own message.Nodes are cluster-scoped, so the chart adds a ClusterRole that can only
listnodesandpods, bound to the computing unit manager's service account. This is the one new permission: the manager can now list pods in every namespace, where it could previously see only its own pool.Not included. The panel that shows it (#6482) and telling the owner on terminate (#6483).
availableis an upper bound, not a go or no-go: it sums across nodes, so capacity spread thinly over many nodes can still refuse a unit that needs one node's worth, and it ignores the pool's ResourceQuota, node placement (taints, node selectors, runtime-class scheduling), pod-level resources and native sidecars. The ClusterRole is unconditional, with no chart value to turn it off.Any related issues, documentation, discussions?
Closes #6481. Part of #6476.
Feeds the panel in #6482 and follows #8888, which added the page.
How was this PR tested?
Tests were added for the aggregation, the client wrapper, the guard and the endpoint. They cover node and pod filtering (cordoned, not Ready, no Ready condition, no status, unbound pods, finished pods), the effective-request rule (container sum, init containers, overhead, containers with no resources), decimal and fractional quantities, a custom GPU resource key,
availablefloored at zero, the wrapper reading nodes and the unfinished pods of every namespace, the 404 on a non-Kubernetes deployment, a Kubernetes failure keeping its message, and the JSON field names the panel will read. The tests were written first and watched fail on a stub, apart from the JSON field-name test, which pins the response shape. Breaking the aggregation on purpose (finished pods counted, init containers summed instead of maxed, no floor at zero, a not-Ready node counted, a cordoned node counted, overhead dropped) turns at least one test red each time.The first command passes 107 tests and the second passes 289.
scalafmtCheckAllandscalafixAll --checkran clean. The ClusterRole was checked by rendering its template alone withhelm templateagainst the chart'svalues.yaml(rendering the whole chart needs its subcharts downloaded) and asserting it grants exactlylistonnodesandpodsand is bound to the manager's service account, andbin/k8s/tests/test_helm_values.shpasses. Not exercised: a live Kubernetes cluster, since the local stack has none, so the Kubernetes calls are only checked against a stubbed client, and the endpoint over HTTP.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code, Claude Sonnet 5.5