feat(metrics): expose orphaned vGPU mdev gauge - #471
Draft
yummybomb wants to merge 1 commit into
Draft
Conversation
Add hypeman_gpu_mdevs_total{state="claimed"|"orphaned"}, computed in the
instance metrics callback by comparing host mdevs against the mdev UUIDs
stored on instances. An mdev no instance references holds a vGPU slot that
only startup reconciliation would release, and until now the only way to
see one was to diff two independently scraped gauges on a dashboard.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Adds a
hypeman_gpu_mdevs_totalgauge withstate="claimed"andstate="orphaned", emitted from the existing instance metrics callback on hosts that have mdevs present.claimed: mdevs under/sys/bus/mdev/deviceswhose UUID matches theGPUMdevUUIDstored on some instance.orphaned: mdevs no instance references. Each one holds a vGPU slot that nothing will release untilReconcileMdevsruns at the next API startup.Why
Leaked mdevs are currently only visible by subtracting used GPU slots from a count of running instances on a dashboard. That derivation has to guess which instances are GPU-backed (there is no
gpulabel onhypeman_instances_total), hardcodes host capacity, and mixes two gauges that are scraped at different instants, so it jitters and can't be alerted on. This gauge answers the question directly from one snapshot, using the same definition the startup reconciliation applies.Notes
hypeman_resources_gpu_slotsis gated on GPU presence. Dashboards should useor vector(0)if they want a flat line on idle GPU hosts; an alert on> 0works as-is.ListMdevDevicesis a directory read plus a couple of readlinks per mdev, bounded by the VF count, so per-collect cost is negligible.Testing
go vet ./lib/instances/on linux andGOOS=darwincross-vet.go test ./lib/instances/ -run 'TestCountGPUMdevs|Metric'passes, including the new unit test for the claimed/orphaned split.🤖 Generated with Claude Code