Skip to content

feat: add hami_gpu_device_health metric to scheduler - #2617

Closed
manoj-1407 wants to merge 1 commit into
Project-HAMi:masterfrom
manoj-1407:feat/scheduler-gpu-device-health
Closed

feat: add hami_gpu_device_health metric to scheduler#2617
manoj-1407 wants to merge 1 commit into
Project-HAMi:masterfrom
manoj-1407:feat/scheduler-gpu-device-health

Conversation

@manoj-1407

@manoj-1407 manoj-1407 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:
scheduler was silently skipping unhealthy GPUs during scoring using
DeviceUsage.Health but nothing ever made it to Prometheus. only way
to know a device was unhealthy was manually checking node annotations.
added hami_gpu_device_health gauge (1=healthy, 0=unhealthy) so you
can actually alert on it.

Which issue(s) this PR fixes:
Fixes #2612

Special notes for your reviewer:
same 0/1 pattern as hami_mig_device_info. descriptor kept local to
the function like everything else in there.

Does this PR introduce a user-facing change?:
yes — hami_gpu_device_health gauge

I used Claude to help identify this gap. I reviewed the code and
understand the implementation.

Summary by CodeRabbit

  • New Features
    • Added a Prometheus metric reporting the health status of each GPU device.
    • Healthy devices report 1; unhealthy devices report 0.
    • Metrics include node, device UUID, index, and device type details.

DeviceUsage.Health is used internally to skip unhealthy devices in Fit()
but was never emitted as a Prometheus metric. Operators have no way to
alert on an unhealthy GPU without inspecting node annotations manually.

Add hami_gpu_device_health gauge (1=healthy, 0=unhealthy) in
collectNodeMetrics, with label set {node, device_uuid, device_index,
device_type} consistent with hami_gpu_memory_limit_bytes.

Signed-off-by: G. Manoj Kumar <manojkumar148700@gmail.com>
Signed-off-by: manoj-1407 <manojkumar148700@gmail.com>
@hami-robot hami-robot Bot added the kind/feature new function label Aug 12, 2026
@hami-robot
hami-robot Bot requested a review from archlitchi August 12, 2026 08:42
@hami-robot
hami-robot Bot requested a review from wawa0210 August 12, 2026 08:42
@hami-robot

hami-robot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: manoj-1407
Once this PR has been reviewed and has the lgtm label, please assign dsfans2014 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the size/M label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4675b525-0c18-4f8b-8f48-d52c1306ae5e

📥 Commits

Reviewing files that changed from the base of the PR and between bb1a9fa and 693649f.

📒 Files selected for processing (2)
  • cmd/scheduler/metrics.go
  • cmd/scheduler/metrics_test.go

📝 Walkthrough

Walkthrough

The scheduler now exposes hami_gpu_device_health for each GPU device. The metric uses node, UUID, index, and device type labels. Healthy devices report 1; unhealthy devices report 0. Tests verify metric names, labels, and values.

Changes

GPU device health metrics

Layer / File(s) Summary
Define and collect device health metric
cmd/scheduler/metrics.go, cmd/scheduler/metrics_test.go
The scheduler defines and emits hami_gpu_device_health with device and node labels. The collector test validates healthy and unhealthy metric values.
Estimated code review effort: 2 (Simple) ~10 minutes

Possibly related PRs

Suggested reviewers: kunwarsidhu47, archlitchi

Poem

A rabbit sees gauges, both steady and bright,
One for the healthy, zero for the plight.
With labels aligned and tests in a row,
GPU health now has metrics to show.
Hop, scrape, repeat!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added scheduler metric.
Linked Issues check ✅ Passed The changes implement the requested metric, labels, health values, scheduler integration, and unit test coverage for issue #2612.
Out of Scope Changes check ✅ Passed The changes are limited to the requested scheduler metric and its unit test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread cmd/scheduler/metrics.go
"Realized MIG instance identity and scheduler placement",
[]string{"node", "device_uuid", "device_index", "mig_uuid", "profile", "gpu_instance_id", "compute_instance_id", "placement_start", "placement_size"}, nil,
)
nodeGPUDeviceHealthDesc := prometheus.NewDesc(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name says gpu but this loop runs for every backend. on purpose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's intentional — Health is set on all device types, the name reflects what the metric measures rather than which backend it's coming from

Comment thread cmd/scheduler/metrics.go
}
}

healthVal := float64(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is health live at scrape time or a cached value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a cached value from the scheduler's in-memory device list, same as the other metrics in collectNodeMetrics

Comment thread cmd/scheduler/metrics.go
}
}

healthVal := float64(0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a node has zero devices in devicelists, does this metric emit anything for that node at all?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing gets emitted in that case, the loop just doesn't run — same behavior as the existing MIG metric

@manoj-1407

Copy link
Copy Markdown
Contributor Author

@mesutoezdil hey, any specific reason for closing? happy to address any concerns

@mesutoezdil

Copy link
Copy Markdown
Contributor

we have no time and energy for llm answers. read again the contribution rules.
you should know your codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: expose hami_gpu_device_health as a Prometheus metric in scheduler

2 participants