Merge pull request #366 from uniemimu/master

topology: avoid unnecessary warning prints
This commit is contained in:
Ed Bartosh 2020-04-17 13:59:15 +03:00 committed by GitHub
commit 0a7b6a7ea0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -270,6 +270,7 @@ func GetTopologyInfo(devs []string) (*pluginapi.TopologyInfo, error) {
} }
for _, hint := range hints { for _, hint := range hints {
if hint.NUMAs != "" {
for _, nNode := range strings.Split(hint.NUMAs, ",") { for _, nNode := range strings.Split(hint.NUMAs, ",") {
nNodeID, err := strconv.ParseInt(strings.TrimSpace(nNode), 10, 64) nNodeID, err := strconv.ParseInt(strings.TrimSpace(nNode), 10, 64)
if err != nil { 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 }) sort.Slice(result.Nodes, func(i, j int) bool { return result.Nodes[i].ID < result.Nodes[j].ID })
return &result, nil return &result, nil
} }

View File

@ -373,10 +373,10 @@ func TestGetTopologyInfo(t *testing.T) {
expectedErr: true, expectedErr: true,
}, },
{ {
name: "incorrect numa node ID", name: "valid: missing numa node ID",
input: []string{"/dev/random"}, input: []string{"/dev/random"},
output: nil, output: &pluginapi.TopologyInfo{},
expectedErr: true, expectedErr: false,
}, },
} }
for _, test := range cases { for _, test := range cases {