Repository navigation
Conversation
DetectHostCapacity on Linux reads the chip from /proc/device-tree/model with its trailing NUL stripped, else the first "model name" or "Model" line in /proc/cpuinfo, else leaves it empty. It goes through the same printable-prefix and 128-byte limit as on darwin. Memory is NewHostMemoryProvider().TotalMemory(), so a cgroup limit below MemTotal is what the capacity reports. hostCapacityFromSysctl and its test move into the darwin files, and the stub for other OSes returns an empty HostCapacity, so the sysctl parser is not dead code on Linux. The MetalNodeCapacity field comments are now host-neutral: memory is unified memory on a Mac and RAM under the agent's cgroup limit on Linux, the chip is the CPU brand string on macOS and the device-tree or cpuinfo model name on Linux, and GPU cores and the Metal version are reported on macOS only. The generated CRDs, the chart's CRD and the CRD reference page carry the new descriptions. Fixes defilantech#2518 Signed-off-by: Christian Nuss <cnuss@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Nov 14, 2026
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
DetectHostCapacitynow has a Linux implementation inpkg/agent/hostcapacity_linux.go. The chip is/proc/device-tree/modelwith its trailing NUL stripped when the board has a device tree, otherwise the firstmodel nameorModelline in/proc/cpuinfo, otherwise empty. It goes through the same printable-prefix filter and 128-byte limit as the darwin reader, so the controller accepts whatever it reports. Memory comes fromNewHostMemoryProvider().TotalMemory(), theLinuxMemoryProviderfrom #2531, so a cgroup limit belowMemTotalis what the MetalNode shows, the same figure the memory budget uses.To keep the dead-code guard passing with GOOS=linux,
hostCapacityFromSysctland its test move from the shared files intohostcapacity_darwin.goandhostcapacity_darwin_test.go. The stub for other OSes (!darwin && !linux) now returns an emptyHostCapacitydirectly. macOS behaviour is unchanged.On main the agent still exits at the Metal check on Linux, so for now this code runs only in tests. #2520 makes it reachable.
Why
Off macOS,
DetectHostCapacityreports nothing, so a Linux host'sMetalNodewould show no chip and no memory in its capacity.Part of #2481.
Fixes #2518
How
hostChipFromProctakes areadFilefunction, so the tests can use a fake/proc. They cover a device-tree model with its trailing NUL, the cpuinfo fallback when there is no device tree, and no/procat all, which gives an empty chip rather than a guess.TestDetectHostCapacityOnLinuxruns the real reader and checks that memory is non-zero and no Metal fields are set.On a real board: a Raspberry Pi 5 (Debian 13, arm64) ran the agent built from the epic branch (
7df0d2b9, which carries this slice). Its MetalNode capacity showedchip: "Raspberry Pi 5 Model B Rev 1.1", which matches/proc/device-tree/model, andmemory: 8255824Ki, which matchesMemTotal. That systemd user unit has noMemoryMax, so nothing capped it.Under a cgroup limit: a small program calling
agent.DetectHostCapacity()in agolang:1.27.4container under--memory 3gprintedMemoryBytes:3221225472, which is the cgroup'smemory.max, while/proc/meminfoshowedMemTotal: 8122332 kB(about 8 GB). The chip was empty there, because that VM has no device-tree model and its cpuinfo has no model name line.What I ran on this branch:
go build ./...andGOOS=linux go build ./...: both build.GOOS=linux bin/golangci-lint run ./...andGOOS=darwin bin/golangci-lint run ./...:0 issues.for each.make lint-deadcodeandGOOS=linux make lint-deadcode:0 issues.for each.go test -count=1 ./pkg/agent/ ./api/...andgo test -count=1 ./cmd/metal-agent/on macOS: allok.golang:1.27.4container,go test -count=1 ./pkg/agent/ -run 'TestHostChipFromProc|TestDetectHostCapacityOnLinux|TestMetalVersionString|TestLinuxMemory': all pass.make chart-crdsandmake docs-reference: running them a second time changed nothing more, andmake check-docs-referenceexits 0.make gate BASE_REF=origin/main: regen, drift, fmt, copyright, vet and lint passed. The test step's only failure wasTestOMLXBindHostOverrideReachesDaemon, a known flake in a path this PR doesn't touch, which passed 3/3 rerun alone.Checklist
make testpasses locallymake lintpasses locallygit commit -s) per DCOMiscellaneous fixes
MetalNodeCapacityfield comments inapi/v1alpha1/metalnode_types.godescribed only a Mac. They now describe any host.memoryBytesis unified memory on a Mac and RAM under the agent's cgroup limit on Linux.chipis the CPU brand string on macOS and the device-tree model or cpuinfo model name on Linux.gpuCoresandmetalVersionare reported on macOS only. The regenerated CRD, the chart's copy anddocs/site/reference/crds.mdcarry the new descriptions.Assisted-by: Claude Code (Claude Opus 5.5) split this out of #2482, wrote the description and ran the checks above in my session.