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,17 +270,19 @@ func GetTopologyInfo(devs []string) (*pluginapi.TopologyInfo, error) {
}
for _, hint := range hints {
for _, nNode := range strings.Split(hint.NUMAs, ",") {
nNodeID, err := strconv.ParseInt(strings.TrimSpace(nNode), 10, 64)
if err != nil {
return nil, errors.Wrapf(err, "unable to convert numa node %s into int64", nNode)
}
if nNodeID < 0 {
return nil, errors.Wrapf(err, "numa node is negative: %d", nNodeID)
}
if _, ok := nodeIDs[nNodeID]; !ok {
result.Nodes = append(result.Nodes, &pluginapi.NUMANode{ID: nNodeID})
nodeIDs[nNodeID] = struct{}{}
if hint.NUMAs != "" {
for _, nNode := range strings.Split(hint.NUMAs, ",") {
nNodeID, err := strconv.ParseInt(strings.TrimSpace(nNode), 10, 64)
if err != nil {
return nil, errors.Wrapf(err, "unable to convert numa node %s into int64", nNode)
}
if nNodeID < 0 {
return nil, errors.Wrapf(err, "numa node is negative: %d", nNodeID)
}
if _, ok := nodeIDs[nNodeID]; !ok {
result.Nodes = append(result.Nodes, &pluginapi.NUMANode{ID: nNodeID})
nodeIDs[nNodeID] = struct{}{}
}
}
}
}

View File

@ -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 {