podresource: do not export NUMA topology if it's empty

If device plugin returns device without topology, keep it internaly
as NUMA node -1, it helps at podresources level to not export NUMA
topology, otherwise topology is exported with NUMA node id 0,
which is not accurate.

It's imposible to unveile this bug just by tracing json.Marshal(resp)
in podresource client, because NUMANodes field ID has json property
omitempty, in this case when ID=0 shown as emtpy NUMANode.
To reproduce it, better to iterate on devices and just
trace dev.Topology.Nodes[0].ID.

Signed-off-by: Alexey Perevalov <alexey.perevalov@huawei.com>
This commit is contained in:
Alexey Perevalov
2021-06-28 13:03:28 +00:00
parent f840bd719d
commit bb81101570
7 changed files with 294 additions and 22 deletions

View File

@@ -84,6 +84,11 @@ func updateImageAllowList() {
} else {
framework.ImagePrePullList.Insert(gpuDevicePluginImage)
}
if kubeVirtPluginImage, err := getKubeVirtDevicePluginImage(); err != nil {
klog.Errorln(err)
} else {
framework.ImagePrePullList.Insert(kubeVirtPluginImage)
}
}
func getNodeProblemDetectorImage() string {
@@ -254,3 +259,23 @@ func getSRIOVDevicePluginImage() (string, error) {
}
return ds.Spec.Template.Spec.Containers[0].Image, nil
}
//TODO generilize this function with above one
// getKubeVirtDevicePluginImage returns the image of SRIOV device plugin.
func getKubeVirtDevicePluginImage() (string, error) {
data, err := e2etestfiles.Read(KubeVirtDevicePluginDSYAML)
if err != nil {
return "", fmt.Errorf("failed to read the device plugin manifest: %w", err)
}
ds, err := e2emanifest.DaemonSetFromData(data)
if err != nil {
return "", fmt.Errorf("failed to parse the device plugin image: %w", err)
}
if ds == nil {
return "", fmt.Errorf("failed to parse the device plugin image: the extracted DaemonSet is nil")
}
if len(ds.Spec.Template.Spec.Containers) < 1 {
return "", fmt.Errorf("failed to parse the device plugin image: cannot extract the container from YAML")
}
return ds.Spec.Template.Spec.Containers[0].Image, nil
}