Repository navigation
feat(infra): show allocatable capacity and utilization for Kubernetes nodes - #1390
Conversation
… nodes The Nodes views only showed CPU cores in use, so there was no way to tell whether a node was full. Node queries now merge k8s_cluster allocatable CPU/memory with kubelet usage and return usage/allocatable fractions. - listNodesQuery / nodeDetailSummaryQuery: cpuAllocatable, memoryUsage (working set), memoryAllocatable, cpuUtilization, memoryUtilization - nodeGaugeTimeseriesQuery: optional capacityMetricName for per-bucket utilization; node charts gain CPU / allocatable, Memory, Memory / allocatable - string attributes use anyIf(!= '') so kubelet version and node uid (set only by k8s_cluster) are no longer blank - the list keeps requiring kubelet usage (HAVING) so cluster-only nodes stay out, matching the facets - benchmark fixtures for listNodesQuery and nodeDetailSummaryQuery
Maple review🟢 Confidence 8/10 · likely safe to merge Node queries now merge k8s_cluster allocatable CPU/memory with kubelet usage and return 0-1 utilization; domain schemas, the API mapper and the Nodes UI carry the new fields. Contained, and the SQL, helper and formatter tests pin the new behavior.
What was checked
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 21 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # packages/backend/src/queries/query-helpers.test.ts
Maple review🟢 Confidence 9/10 · safe to merge Adds allocatable CPU/memory capacity and usage/allocatable utilization to the Kubernetes Nodes list and node detail: the fractions are computed in ClickHouse, mapped through the domain schemas, and rendered as meters with used/allocatable captions. Contained, consistent across the stack, and safe to merge.
What was checked
|
Problem
Infrastructure > Kubernetes > Nodes only showed CPU cores in use (
k8s.node.cpu.usage) with no capacity next to it, so nobody, user or agent, could tell whether a node was full.Receiver facts (contrib v0.151.0, as pinned in
deploy/k8s-infra/builder-config.yaml)Checked against
receiver/k8sclusterreceiver/internal/node/nodes.goatv0.151.0:k8s.node.allocatable_cpu{cpu}(cores,MilliValue()/1000)k8s.node.allocatable_memoryByk8s.node.memory.working_setByAt this version the allocatable metrics are not in
metadata.yaml. They are only emitted for the types listed inallocatable_types_to_report, and none are reported by default. The chart already setsallocatableTypesToReport: [cpu, memory](it has since the chart was added), so no chart change is needed. I added a comment invalues.yamlsaying the Nodes view depends on that setting.Changes
packages/query-engine/src/ch/queries/infra.ts)listNodesQuery/nodeDetailSummaryQuerynow also returncpuAllocatable,memoryUsage(working set),memoryAllocatable, andcpuUtilization/memoryUtilization(usage / allocatable as a 0-1 fraction). Each is 0 when the value was not collected.nodeGaugeTimeseriesQuerytakes an optionalcapacityMetricNameand returns usage / allocatable for each bucket.anyIf(attr != ''). Fix:k8s.kubelet.versionandk8s.node.uidare set only on k8s_cluster resources, but the old query only scanned kubeletstats metrics, so the kubelet version was always blank. It comes through now.HAVING countIf(k8s.node.cpu.usage) > 0clause. Nodes reported only by k8s_cluster (EKS Fargate virtual nodes, nodes without the DaemonSet) stay out, which matches the node facets and the presence probe.NodeInfraTimeseriesRequest.metricgainscpu_utilization,memory_usageandmemory_utilization, with the unitspercentandbytes.listNodesQueryandnodeDetailSummaryQueryand removed both from the exemption list.utilizationfixture fornodeGaugeTimeseriesQuery.Follow-up
The MCP infra tools (
list_infra,inspect_infra, merged in #1387) don't use these fields yet. The node view still says capacity is not reported. A follow-up can readcpuAllocatable/memoryAllocatableand the utilization fractions fromlistNodesQuery/nodeDetailSummaryQuery. This PR only updates their fixture world (apps/ai/src/mcp/__evals__/infra-world.ts) so its node rows match the wider row schema.Testing
bunx vitest runoninfra.test.ts,benchmark/catalog.test.ts,catalog.baseline.test.ts(query-engine),query-helpers.test.ts(backend), andformat.test.ts/infra-correlations.test.ts(web): all pass.@maple/query-engine,@maple/domainand@maple/backendpass.@maple/apiand@maple/webreport only errors from unbuilt workspace lib dists (@maple-dev/effect-sdk,@maple-dev/alchemy). None are in files this PR touches.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.