mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #112387 from mythi/kubelet-devicemanager-topologyinfo
devicemanager: do not leak empty TopologyInfo to TopologyManager
This commit is contained in:
commit
c45ca46cdb
@ -137,9 +137,9 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *ManagerImpl) deviceHasTopologyAlignment(resource string) bool {
|
func (m *ManagerImpl) deviceHasTopologyAlignment(resource string) bool {
|
||||||
// If any device has Topology set, we assume they care about alignment.
|
// If any device has Topology NUMANodes available, we assume they care about alignment.
|
||||||
for device := range m.allDevices[resource] {
|
for _, device := range m.allDevices[resource] {
|
||||||
if m.allDevices[resource][device].Topology != nil {
|
if device.Topology != nil && len(device.Topology.Nodes) > 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ func TestGetTopologyHints(t *testing.T) {
|
|||||||
return tc.expectedHints[r][i].LessThan(tc.expectedHints[r][j])
|
return tc.expectedHints[r][i].LessThan(tc.expectedHints[r][j])
|
||||||
})
|
})
|
||||||
if !reflect.DeepEqual(hints[r], tc.expectedHints[r]) {
|
if !reflect.DeepEqual(hints[r], tc.expectedHints[r]) {
|
||||||
t.Errorf("%v: Expected result to be %v, got %v", tc.description, tc.expectedHints[r], hints[r])
|
t.Errorf("%v: Expected result to be %#v, got %#v", tc.description, tc.expectedHints[r], hints[r])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,6 +1006,8 @@ func getCommonTestCases() []topologyHintTestCase {
|
|||||||
"testdevice": {
|
"testdevice": {
|
||||||
{ID: "Dev1"},
|
{ID: "Dev1"},
|
||||||
{ID: "Dev2"},
|
{ID: "Dev2"},
|
||||||
|
{ID: "Dev3", Topology: &pluginapi.TopologyInfo{Nodes: []*pluginapi.NUMANode{}}},
|
||||||
|
{ID: "Dev4", Topology: &pluginapi.TopologyInfo{Nodes: nil}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedHints: map[string][]topologymanager.TopologyHint{
|
expectedHints: map[string][]topologymanager.TopologyHint{
|
||||||
|
Loading…
Reference in New Issue
Block a user