Repository navigation
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 53830 +39
Branches 6707 6709 +2
============================================
+ Hits 49824 49859 +35
- Misses 2313 2315 +2
- 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:
|
This branch has not been deployed
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