Skip to content

fix: accumulate devices in node map instead of overwriting each iteration#105

Open
peachest wants to merge 1 commit into
Project-HAMi:mainfrom
peachest:fix-accumulate-devices
Open

fix: accumulate devices in node map instead of overwriting each iteration#105
peachest wants to merge 1 commit into
Project-HAMi:mainfrom
peachest:fix-accumulate-devices

Conversation

@peachest

@peachest peachest commented Jun 26, 2026

Copy link
Copy Markdown

Problem

In updateLocalNodes(), when iterating over a node's devices, the code uses bizNode.Devices as the base slice for append:

n[node.UID].Devices = append(bizNode.Devices, &biz.DeviceInfo{...})

bizNode is created once per node by fetchNodeInfo() and its Devices field is always nil (it only sets metadata like IP, Name, etc.). This means every iteration overwrites the previous device instead of accumulating:

  • A node with multiple devices (e.g. Ascend910B with 4 cards) loses all but the last device
  • When multiple providers match the same node, devices from all but the last provider are lost

Fix

Use the accumulated slice n[node.UID].Devices instead of bizNode.Devices:

n[node.UID].Devices = append(n[node.UID].Devices, &biz.DeviceInfo{...})

So each device is appended to the growing list in the map entry.

Changes

server/internal/data/node.go — 1 line changed, 1 insertion, 1 deletion

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where device information could be attached to the wrong node record during node updates.
    • Improved consistency of node/device data shown in the system when refreshed from provider results.

…tion

Signed-off-by: houyuxi <yuxi.hou@transwarp.io>
@hami-robot

hami-robot Bot commented Jun 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: peachest

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 commented Jun 26, 2026

Copy link
Copy Markdown

Welcome @peachest! It looks like this is your first PR to Project-HAMi/HAMi-WebUI 🎉

@coderabbitai

coderabbitai Bot commented Jun 26, 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: ba336d95-efd0-45fd-bc74-2c32c8c6e9de

📥 Commits

Reviewing files that changed from the base of the PR and between 8f42445 and de33d85.

📒 Files selected for processing (1)
  • server/internal/data/node.go

📝 Walkthrough

Walkthrough

updateLocalNodes now appends fetched device entries to the node already stored in the in-progress map, instead of the newly fetched node variable.

Changes

Local node device append

Layer / File(s) Summary
Append target in node update
server/internal/data/node.go
updateLocalNodes now appends fetched DeviceInfo values to the node stored in n[node.UID] instead of the freshly fetched node variable.

Estimated review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through nodes at dawn so bright,
One device list found its proper light.
In the map it rests, all snug and neat,
A carrot-calm fix with tidy beat.
Hops and bits now land just right.

🚥 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 describes the main fix: accumulating devices in the node map entry rather than losing them each iteration.
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

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

@hami-robot hami-robot Bot added the size/XS label Jun 26, 2026
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.

1 participant