mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 05:46:16 +00:00
Sync all CPU and device state before generating TopologyHints for them
This ensures that we have the most up-to-date state when generating topology hints for a container. Without this, it's possible that some resources will be seen as allocated, when they are actually free.
This commit is contained in:
parent
d9adf20360
commit
58f3554ebe
@ -229,6 +229,8 @@ func (m *manager) State() state.Reader {
|
||||
}
|
||||
|
||||
func (m *manager) GetTopologyHints(pod v1.Pod, container v1.Container) map[string][]topologymanager.TopologyHint {
|
||||
// Garbage collect any stranded resources before providing TopologyHints
|
||||
m.removeStaleState()
|
||||
// Delegate to active policy
|
||||
return m.policy.GetTopologyHints(m.state, pod, container)
|
||||
}
|
||||
|
@ -28,8 +28,10 @@ import (
|
||||
// ensures the Device Manager is consulted when Topology Aware Hints for each
|
||||
// container are created.
|
||||
func (m *ManagerImpl) GetTopologyHints(pod v1.Pod, container v1.Container) map[string][]topologymanager.TopologyHint {
|
||||
deviceHints := make(map[string][]topologymanager.TopologyHint)
|
||||
// Garbage collect any stranded device resources before providing TopologyHints
|
||||
m.updateAllocatedDevices(m.activePods())
|
||||
|
||||
deviceHints := make(map[string][]topologymanager.TopologyHint)
|
||||
for resourceObj, requestedObj := range container.Resources.Limits {
|
||||
resource := string(resourceObj)
|
||||
requested := int(requestedObj.Value())
|
||||
@ -66,8 +68,6 @@ func (m *ManagerImpl) deviceHasTopologyAlignment(resource string) bool {
|
||||
}
|
||||
|
||||
func (m *ManagerImpl) getAvailableDevices(resource string) sets.String {
|
||||
// Gets Devices in use.
|
||||
m.updateAllocatedDevices(m.activePods())
|
||||
// Strip all devices in use from the list of healthy ones.
|
||||
return m.healthyDevices[resource].Difference(m.allocatedDevices[resource])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user