Skip to content

use exported_namespace/pod labels for NVIDIA task metrics queries - #114

Open
Shenhan11 wants to merge 1 commit into
Project-HAMi:mainfrom
Shenhan11:feature/shenhan
Open

use exported_namespace/pod labels for NVIDIA task metrics queries#114
Shenhan11 wants to merge 1 commit into
Project-HAMi:mainfrom
Shenhan11:feature/shenhan

Conversation

@Shenhan11

@Shenhan11 Shenhan11 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Enhanced GPU admin tables with status filtering, role-based node filtering, richer allocation/usage visuals, and a compute configuration column with tooltip help.
    • Updated node role display across node overview/details.
  • Bug Fixes

    • Corrected NVIDIA GPU task-level metric queries to use the correct exported label names.
    • Improved GPU and node utilization reporting accuracy and data consistency (including usage fields and limits).
  • API & Localization

    • Extended API responses and filters (health, keyword/role, node IP, usage, and resource limits).
    • Updated English and Chinese UI labels to match the new fields and controls.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change expands GPU, node, and container resource data across backend APIs and services, adds node and card administration filters and usage displays, adds task compute configuration details, updates localization, and corrects NVIDIA metric label selectors.

Changes

Resource contracts and data mapping

Layer / File(s) Summary
API contracts and Kubernetes data mapping
server/api/v1/*.proto, server/internal/biz/*.go, server/internal/data/*.go
Adds node roles, GPU usage and IP fields, container limits, and maps Kubernetes labels and resource limits into backend models.

Backend resource services

Layer / File(s) Summary
Node, GPU, and container service propagation
server/internal/service/*.go
Supports node keyword/role filtering, node and GPU utilization metrics, GPU health filtering and IP enrichment, container limits, and conditional device type assignment.

NVIDIA metric selectors

Layer / File(s) Summary
Update NVIDIA task metric selectors
server/internal/exporter/exporter.go
NVIDIA core and memory utilization queries now use exported_namespace and exported_pod labels while retaining the container selector.

vGPU administration views

Layer / File(s) Summary
Card, node, and task administration UI
packages/web/projects/vgpu/views/{card,node,task}/admin/*
Adds card health filtering, paired allocation and usage indicators, node role and IP displays, node usage filtering, and task compute configuration tooltips.

Localization

Layer / File(s) Summary
Administration labels
packages/web/src/locales/{en,zh}.js
Adds translated labels for node roles, resource usage, card status, and task compute configuration.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: enhancement

Poem

A rabbit spots new metrics glow,
With roles and health now set to show.
Cards pair usage, tasks explain,
NVIDIA labels match again.
Hop through every view with cheer!

🚥 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 correctly describes one real change in the PR: switching NVIDIA task metric queries to exported_namespace/exported_pod labels.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@hami-robot hami-robot Bot added the size/XS label Jul 23, 2026
@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jul 23, 2026
Signed-off-by: Shenhan11 <han.shen@dynamia.ai>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/internal/service/node.go (1)

160-171: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve metric availability information.

This helper currently returns only a value map, so callers cannot distinguish “no sample” from “query failed.” Return an error or validity status alongside the map and handle it explicitly at the API boundary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/internal/service/node.go` around lines 160 - 171, The queryNodeGauge
helper currently hides query failures by returning only an empty map. Update
NodeService.queryNodeGauge to return the gauge map together with an error or
explicit validity status, propagate the QueryInstant failure, and update its
API-boundary callers to handle that result distinctly from a successful query
with no samples.
🧹 Nitpick comments (4)
packages/web/projects/vgpu/views/card/admin/index.vue (1)

204-240: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate renderPercentPair implementation.

Nearly identical to the renderPercentPair added in packages/web/projects/vgpu/views/node/admin/index.vue. Consider extracting to a shared composable/util. See consolidated comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/web/projects/vgpu/views/card/admin/index.vue` around lines 204 -
240, Extract the duplicated renderPercentPair logic from the card admin view and
the node admin view into a shared composable or utility, including its clamping,
formatting, progress rendering, and resource-color behavior. Replace both local
implementations with the shared symbol while preserving their existing output.
packages/web/projects/vgpu/views/node/admin/index.vue (2)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract duplicated renderPercentPair/getNodeRoleText helpers into a shared composable. This PR introduces the same renderPercentPair implementation in two files and the same getNodeRoleText implementation in two other files; all four copies are verbatim duplicates with no shared source.

  • packages/web/projects/vgpu/views/node/admin/index.vue#L128-172: extract both getNodeRoleText and renderPercentPair into a shared composable/util (e.g. ~/vgpu/hooks/useResourceDisplay.js) and import here.
  • packages/web/projects/vgpu/views/card/admin/index.vue#L204-240: replace the local renderPercentPair with the shared implementation.
  • packages/web/projects/vgpu/views/node/admin/Detail.vue#L362-377: replace the local getNodeRoleText with the shared implementation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/web/projects/vgpu/views/node/admin/index.vue` at line 1, Extract the
duplicated getNodeRoleText and renderPercentPair helpers from the node and card
admin views into one shared composable or utility, such as useResourceDisplay.
Export both helpers there, then import and use them in node/admin/index.vue,
card/admin/index.vue, and node/admin/Detail.vue, removing the local duplicate
implementations while preserving their existing behavior.

128-172: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated getNodeRoleText/renderPercentPair helpers.

renderPercentPair duplicates the one in card/admin/index.vue; getNodeRoleText duplicates the one in Detail.vue. Consider extracting both into shared composables. See consolidated comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/web/projects/vgpu/views/node/admin/index.vue` around lines 128 -
172, Extract the duplicated getNodeRoleText and renderPercentPair helpers from
the node admin views into shared composables, then update index.vue and the
corresponding card/admin/index.vue and Detail.vue usages to import and reuse
them. Preserve the existing translations, percentage clamping, formatting,
progress rendering, and resource-color behavior.
packages/web/projects/vgpu/views/node/admin/Detail.vue (1)

362-377: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated getNodeRoleText helper.

Identical implementation to the one added in node/admin/index.vue. See consolidated comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/web/projects/vgpu/views/node/admin/Detail.vue` around lines 362 -
377, Remove the duplicated getNodeRoleText helper from Detail.vue and reuse the
existing shared or index.vue implementation identified in the consolidated
comment. Update the node role column renderer in detailColumns to call that
single implementation while preserving the current translations and unknown-role
fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/internal/service/node.go`:
- Around line 55-72: Extract the CoreUsage and MemoryUsage enrichment currently
performed in the GetAllNodes loop into a reusable helper around buildNodeReply.
Apply that helper in both GetAllNodes and GetNode, using the corresponding
coreUsageByNode and memUsageByNode values so both endpoints populate usage
metrics consistently.
- Around line 55-72: Update queryNodeGauge and the node-reply construction
around buildNodeReply so QueryInstant failures preserve metric unavailability
instead of leaving protobuf utilization fields at zero. Propagate query
success/validity alongside each gauge result, and only assign CoreUsage and
MemoryUsage when the corresponding metric query succeeded; otherwise expose the
established unavailable representation to consumers.

---

Outside diff comments:
In `@server/internal/service/node.go`:
- Around line 160-171: The queryNodeGauge helper currently hides query failures
by returning only an empty map. Update NodeService.queryNodeGauge to return the
gauge map together with an error or explicit validity status, propagate the
QueryInstant failure, and update its API-boundary callers to handle that result
distinctly from a successful query with no samples.

---

Nitpick comments:
In `@packages/web/projects/vgpu/views/card/admin/index.vue`:
- Around line 204-240: Extract the duplicated renderPercentPair logic from the
card admin view and the node admin view into a shared composable or utility,
including its clamping, formatting, progress rendering, and resource-color
behavior. Replace both local implementations with the shared symbol while
preserving their existing output.

In `@packages/web/projects/vgpu/views/node/admin/Detail.vue`:
- Around line 362-377: Remove the duplicated getNodeRoleText helper from
Detail.vue and reuse the existing shared or index.vue implementation identified
in the consolidated comment. Update the node role column renderer in
detailColumns to call that single implementation while preserving the current
translations and unknown-role fallback.

In `@packages/web/projects/vgpu/views/node/admin/index.vue`:
- Line 1: Extract the duplicated getNodeRoleText and renderPercentPair helpers
from the node and card admin views into one shared composable or utility, such
as useResourceDisplay. Export both helpers there, then import and use them in
node/admin/index.vue, card/admin/index.vue, and node/admin/Detail.vue, removing
the local duplicate implementations while preserving their existing behavior.
- Around line 128-172: Extract the duplicated getNodeRoleText and
renderPercentPair helpers from the node admin views into shared composables,
then update index.vue and the corresponding card/admin/index.vue and Detail.vue
usages to import and reuse them. Preserve the existing translations, percentage
clamping, formatting, progress rendering, and resource-color behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2440968-f99c-4aab-b4b8-9426f02a3579

📥 Commits

Reviewing files that changed from the base of the PR and between 4346d10 and 063f6de.

📒 Files selected for processing (17)
  • packages/web/projects/vgpu/views/card/admin/index.vue
  • packages/web/projects/vgpu/views/node/admin/Detail.vue
  • packages/web/projects/vgpu/views/node/admin/index.vue
  • packages/web/projects/vgpu/views/task/admin/index.vue
  • packages/web/src/locales/en.js
  • packages/web/src/locales/zh.js
  • server/api/v1/card.proto
  • server/api/v1/container.proto
  • server/api/v1/node.proto
  • server/internal/biz/node.go
  • server/internal/biz/pod.go
  • server/internal/data/node.go
  • server/internal/data/pod.go
  • server/internal/exporter/exporter.go
  • server/internal/service/card.go
  • server/internal/service/container.go
  • server/internal/service/node.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/internal/exporter/exporter.go

Comment thread server/internal/service/node.go Outdated
@FouoF

FouoF commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@hami-robot hami-robot Bot added the lgtm label Jul 27, 2026
@hami-robot

hami-robot Bot commented Jul 27, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: FouoF, Shenhan11

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

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.

2 participants