From da55ef0b9a8c69c913e42473c94b1b22533f42cd Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Thu, 4 Mar 2021 17:12:01 +0100 Subject: [PATCH] node: podresources: list devices without topology It's legal for device plugins to not expose topology informations. Previously, the code was just skipping these devices. Review highlighted is better to report them anyway and let the client application decide if they still want somehow to track them or skip them entirely. Signed-off-by: Francesco Romani --- pkg/kubelet/cm/container_manager.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/kubelet/cm/container_manager.go b/pkg/kubelet/cm/container_manager.go index 05679adb3a9..2296fe024e2 100644 --- a/pkg/kubelet/cm/container_manager.go +++ b/pkg/kubelet/cm/container_manager.go @@ -194,15 +194,26 @@ func containerDevicesFromResourceDeviceInstances(devs devicemanager.ResourceDevi for resourceName, resourceDevs := range devs { for devID, dev := range resourceDevs { - for _, node := range dev.GetTopology().GetNodes() { - numaNode := node.GetID() + topo := dev.GetTopology() + if topo == nil { + // Some device plugin do not report the topology information. + // This is legal, so we report the devices anyway, + // let the client decide what to do. + respDevs = append(respDevs, &podresourcesapi.ContainerDevices{ + ResourceName: resourceName, + DeviceIds: []string{devID}, + }) + continue + } + + for _, node := range topo.GetNodes() { respDevs = append(respDevs, &podresourcesapi.ContainerDevices{ ResourceName: resourceName, DeviceIds: []string{devID}, Topology: &podresourcesapi.TopologyInfo{ Nodes: []*podresourcesapi.NUMANode{ { - ID: numaNode, + ID: node.GetID(), }, }, },