Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmd/internal/labeler/labeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package labeler

import (
"fmt"
"math"
"os"
"os/signal"
"path"
Expand Down Expand Up @@ -205,12 +206,18 @@ func (l *labeler) getNumaNode(gpuName string) int {
return -1
}

numa, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64)
numa, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 32)
if err != nil {
klog.Warning("Can't convert numa_node: ", err)
return -1
}

if numa > math.MaxInt16 {
klog.Warning("Too large numa: ", numa)

return -1
}

return int(numa)
}

Expand Down Expand Up @@ -305,7 +312,9 @@ func (l *labeler) createLabels() error {
numaMapping[numaNode] = numaList
}

l.labels.addNumericLabel(labelNamespace+"memory.max", int64(memoryAmount))
if memoryAmount < math.MaxInt64 {
l.labels.addNumericLabel(labelNamespace+"memory.max", int64(memoryAmount))
}
}

gpuCount := len(gpuNumList)
Expand Down
42 changes: 42 additions & 0 deletions cmd/internal/labeler/labeler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,48 @@ func getTestCases() []testcase {
"gpu.intel.com/tiles": "27",
},
},
{
sysfsdirs: []string{
"card1/device/drm/card1",
"card1/gt/gt0",
},
sysfsfiles: map[string][]byte{
"card1/device/vendor": []byte("0x8086"),
"card1/lmem_total_bytes": []byte("8000"),
"card1/device/numa_node": []byte("2147483648"), // max int32 + 1
},
name: "too large numa node",
memoryOverride: 16000000000,
expectedRetval: nil,
expectedLabels: labelMap{
"gpu.intel.com/millicores": "1000",
"gpu.intel.com/memory.max": "8000",
"gpu.intel.com/gpu-numbers": "1",
"gpu.intel.com/cards": "card1",
"gpu.intel.com/tiles": "1",
},
},
{
sysfsdirs: []string{
"card1/device/drm/card1",
"card1/gt/gt0",
},
sysfsfiles: map[string][]byte{
"card1/device/vendor": []byte("0x8086"),
"card1/lmem_total_bytes": []byte("8000"),
"card1/device/numa_node": []byte("32768"), // max int16 + 1
},
name: "too large numa node",
memoryOverride: 16000000000,
expectedRetval: nil,
expectedLabels: labelMap{
"gpu.intel.com/millicores": "1000",
"gpu.intel.com/memory.max": "8000",
"gpu.intel.com/gpu-numbers": "1",
"gpu.intel.com/cards": "card1",
"gpu.intel.com/tiles": "1",
},
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/fpga/dfl_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (f *DflFME) GetPortsNum() int {
}

n, err := strconv.ParseUint(f.PortsNum, 10, 32)
if err != nil || n >= math.MaxInt {
if err != nil || n > math.MaxInt32 {
return -1
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/fpga/intel_fpga_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (f *IntelFpgaFME) GetPortsNum() int {
}

n, err := strconv.ParseUint(f.PortsNum, 10, 32)
if err != nil || n >= math.MaxInt {
if err != nil || n > math.MaxInt32 {
return -1
}

Expand Down