mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
topology: avoid unnecessary warning prints
Doing strings.Split with a non-empty separator against a potentially empty string (hint.NUMAs) may return an empty string in a slice of size one, which then doesn't parse nicely with ParseInt and results in a repeating warning. It is better to check for hint.NUMAs emptiness before trying to split it. Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
This commit is contained in:
parent
f261b27423
commit
39c934b22f
@ -270,6 +270,7 @@ func GetTopologyInfo(devs []string) (*pluginapi.TopologyInfo, error) {
|
||||
}
|
||||
|
||||
for _, hint := range hints {
|
||||
if hint.NUMAs != "" {
|
||||
for _, nNode := range strings.Split(hint.NUMAs, ",") {
|
||||
nNodeID, err := strconv.ParseInt(strings.TrimSpace(nNode), 10, 64)
|
||||
if err != nil {
|
||||
@ -285,6 +286,7 @@ func GetTopologyInfo(devs []string) (*pluginapi.TopologyInfo, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sort.Slice(result.Nodes, func(i, j int) bool { return result.Nodes[i].ID < result.Nodes[j].ID })
|
||||
return &result, nil
|
||||
}
|
||||
|
@ -373,10 +373,10 @@ func TestGetTopologyInfo(t *testing.T) {
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
name: "incorrect numa node ID",
|
||||
name: "valid: missing numa node ID",
|
||||
input: []string{"/dev/random"},
|
||||
output: nil,
|
||||
expectedErr: true,
|
||||
output: &pluginapi.TopologyInfo{},
|
||||
expectedErr: false,
|
||||
},
|
||||
}
|
||||
for _, test := range cases {
|
||||
|
Loading…
Reference in New Issue
Block a user