Skip to content

Commit 7114445

Browse files
authored
fix parseNvidiaNumaInfo index out of range (#889)
Signed-off-by: bin <[email protected]>
1 parent 8cb8f03 commit 7114445

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/device-plugin/nvidiadevice/nvinternal/plugin/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func parseNvidiaNumaInfo(idx int, nvidiaTopoStr string) (int, error) {
9494
}
9595
klog.V(5).InfoS("nvidia-smi topo -m row output", "row output", words, "length", len(words))
9696
if strings.Contains(words[0], fmt.Sprint(idx)) {
97-
if words[numaAffinityColumnIndex] == "N/A" {
97+
if len(words) <= numaAffinityColumnIndex || words[numaAffinityColumnIndex] == "N/A" {
9898
klog.InfoS("current card has not established numa topology", "gpu row info", words, "index", idx)
9999
return 0, nil
100100
}

pkg/device-plugin/nvidiadevice/nvinternal/plugin/register_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ func Test_parseNvidiaNumaInfo(t *testing.T) {
6767
want: 0,
6868
wantErr: false,
6969
},
70+
{
71+
name: "NUMA Affinity is empty",
72+
idx: 0,
73+
nvidiaTopoStr: `GPU0 CPU Affinity NUMA Affinity GPU NUMA ID
74+
GPU0 X`,
75+
want: 0,
76+
wantErr: false,
77+
},
7078
}
7179

7280
for _, tt := range tests {

0 commit comments

Comments
 (0)