mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
fix allDevices map data race
This commit is contained in:
parent
997cefc9da
commit
b9987eeb6c
@ -646,7 +646,7 @@ func (m *ManagerImpl) devicesToAllocate(podUID, contName, resource string, requi
|
||||
func (m *ManagerImpl) filterByAffinity(podUID, contName, resource string, available sets.String) (sets.String, sets.String, sets.String) {
|
||||
// If alignment information is not available, just pass the available list back.
|
||||
hint := m.topologyAffinityStore.GetAffinity(podUID, contName)
|
||||
if !m.deviceHasTopologyAlignment(resource) || hint.NUMANodeAffinity == nil {
|
||||
if !m.deviceHasTopologyAlignmentLocked(resource) || hint.NUMANodeAffinity == nil {
|
||||
return sets.NewString(), sets.NewString(), available
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymana
|
||||
return deviceHints
|
||||
}
|
||||
|
||||
func (m *ManagerImpl) deviceHasTopologyAlignment(resource string) bool {
|
||||
func (m *ManagerImpl) deviceHasTopologyAlignmentLocked(resource string) bool {
|
||||
// If any device has Topology NUMANodes available, we assume they care about alignment.
|
||||
for _, device := range m.allDevices[resource] {
|
||||
if device.Topology != nil && len(device.Topology.Nodes) > 0 {
|
||||
@ -146,6 +146,12 @@ func (m *ManagerImpl) deviceHasTopologyAlignment(resource string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *ManagerImpl) deviceHasTopologyAlignment(resource string) bool {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
return m.deviceHasTopologyAlignmentLocked(resource)
|
||||
}
|
||||
|
||||
func (m *ManagerImpl) getAvailableDevices(resource string) sets.String {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
@ -456,7 +456,7 @@ func TestTopologyAlignedAllocation(t *testing.T) {
|
||||
}
|
||||
|
||||
alignment := make(map[int]int)
|
||||
if m.deviceHasTopologyAlignment(tc.resource) {
|
||||
if m.deviceHasTopologyAlignmentLocked(tc.resource) {
|
||||
for d := range allocated {
|
||||
if m.allDevices[tc.resource][d].Topology != nil {
|
||||
alignment[int(m.allDevices[tc.resource][d].Topology.Nodes[0].ID)]++
|
||||
|
Loading…
Reference in New Issue
Block a user