Skip to content

fix(scheduler): skip a topology candidate card missing from the node - #6

Closed
Wangmin362 wants to merge 1 commit into
masterfrom
fix/topology-scoremap-nil-deref
Closed

fix(scheduler): skip a topology candidate card missing from the node#6
Wangmin362 wants to merge 1 commit into
masterfrom
fix/topology-scoremap-nil-deref

Conversation

@Wangmin362

Copy link
Copy Markdown
Owner

What type of PR is this?
/kind bug

What this PR does / why we need it:

computeWorstSingleCard and computeBestCombination build deviceScoreMap from the live node, but the candidate cards they iterate come from an earlier snapshot. If a card was dropped from the node in between, deviceScoreMap[uuid] is nil and the next .Scores[...] access panics, taking down the scheduler. This adds a nil check so the missing card is skipped instead.

Which issue(s) this PR fixes:

NONE

Special notes for your reviewer:

Added two unit tests where a candidate UUID is not present on the node. Without the fix they panic with a nil pointer dereference (device.go:946 and :969); with it they pass. go test ./pkg/device/nvidia/, go vet and gofmt are clean.

Does this PR introduce a user-facing change?

The scheduler no longer panics during topology scoring when a candidate card has been removed from the node.

AI Assistant disclosure:

This PR was written with the help of Claude Code. I reviewed and understand the change.

computeWorstSingleCard and computeBestCombination look up deviceScoreMap by the
UUID of candidate cards taken from an earlier snapshot. If a card was dropped from
the node between the snapshot and scoring, the lookup returns nil and the next
.Scores access panics. Skip such cards instead of dereferencing nil.

Signed-off-by: wangmin <wangmin@riseunion.io>
@Wangmin362 Wangmin362 closed this Jul 16, 2026
@Wangmin362
Wangmin362 deleted the fix/topology-scoremap-nil-deref branch July 16, 2026 07:36
@Wangmin362

Copy link
Copy Markdown
Owner Author

Withdrawn. On current master this nil-deref is no longer reachable: Project-HAMi#2046 changed calcScore from the live GetNode pointer to the frozen node.NodeInfo snapshot, so the topology candidate set and the score map now come from the same copy and cannot diverge. It was reachable before Project-HAMi#2046 (live pointer). Not worth a defensive-only patch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant