mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Add GetPodTopologyHints() interface to Topology/CPU/Device Manager
Signed-off-by: Krzysztof Wiatrzyk <k.wiatrzyk@samsung.com>
This commit is contained in:
parent
ec552e6dc6
commit
f5997fe537
@ -81,6 +81,11 @@ type Manager interface {
|
|||||||
// GetCPUs implements the podresources.CPUsProvider interface to provide allocated
|
// GetCPUs implements the podresources.CPUsProvider interface to provide allocated
|
||||||
// cpus for the container
|
// cpus for the container
|
||||||
GetCPUs(podUID, containerName string) []int64
|
GetCPUs(podUID, containerName string) []int64
|
||||||
|
|
||||||
|
// GetPodTopologyHints implements the topologymanager.HintProvider Interface
|
||||||
|
// and is consulted to achieve NUMA aware resource alignment per Pod
|
||||||
|
// among this and other resource controllers.
|
||||||
|
GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint
|
||||||
}
|
}
|
||||||
|
|
||||||
type manager struct {
|
type manager struct {
|
||||||
@ -304,6 +309,13 @@ func (m *manager) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[str
|
|||||||
return m.policy.GetTopologyHints(m.state, pod, container)
|
return m.policy.GetTopologyHints(m.state, pod, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *manager) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
// Garbage collect any stranded resources before providing TopologyHints
|
||||||
|
m.removeStaleState()
|
||||||
|
// Delegate to active policy
|
||||||
|
return m.policy.GetPodTopologyHints(m.state, pod)
|
||||||
|
}
|
||||||
|
|
||||||
type reconciledContainer struct {
|
type reconciledContainer struct {
|
||||||
podName string
|
podName string
|
||||||
containerName string
|
containerName string
|
||||||
|
@ -116,6 +116,10 @@ func (p *mockPolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v1.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *mockPolicy) GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type mockRuntimeService struct {
|
type mockRuntimeService struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,12 @@ func (m *fakeManager) RemoveContainer(containerID string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *fakeManager) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
|
func (m *fakeManager) GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
|
||||||
klog.Infof("[fake cpumanager] Get Topology Hints")
|
klog.Infof("[fake cpumanager] Get Container Topology Hints")
|
||||||
|
return map[string][]topologymanager.TopologyHint{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *fakeManager) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
klog.Infof("[fake cpumanager] Get Pod Topology Hints")
|
||||||
return map[string][]topologymanager.TopologyHint{}
|
return map[string][]topologymanager.TopologyHint{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,4 +34,8 @@ type Policy interface {
|
|||||||
// and is consulted to achieve NUMA aware resource alignment among this
|
// and is consulted to achieve NUMA aware resource alignment among this
|
||||||
// and other resource controllers.
|
// and other resource controllers.
|
||||||
GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint
|
GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint
|
||||||
|
// GetPodTopologyHints implements the topologymanager.HintProvider Interface
|
||||||
|
// and is consulted to achieve NUMA aware resource alignment per Pod
|
||||||
|
// among this and other resource controllers.
|
||||||
|
GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint
|
||||||
}
|
}
|
||||||
|
@ -55,3 +55,7 @@ func (p *nonePolicy) RemoveContainer(s state.State, podUID string, containerName
|
|||||||
func (p *nonePolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
|
func (p *nonePolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *nonePolicy) GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -355,6 +355,10 @@ func (p *staticPolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *staticPolicy) GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// generateCPUtopologyHints generates a set of TopologyHints given the set of
|
// generateCPUtopologyHints generates a set of TopologyHints given the set of
|
||||||
// available CPUs and the number of CPUs being requested.
|
// available CPUs and the number of CPUs being requested.
|
||||||
//
|
//
|
||||||
|
@ -74,6 +74,11 @@ func (h *ManagerStub) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
|
|||||||
return map[string][]topologymanager.TopologyHint{}
|
return map[string][]topologymanager.TopologyHint{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPodTopologyHints returns an empty TopologyHint map
|
||||||
|
func (h *ManagerStub) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
return map[string][]topologymanager.TopologyHint{}
|
||||||
|
}
|
||||||
|
|
||||||
// GetDevices returns nil
|
// GetDevices returns nil
|
||||||
func (h *ManagerStub) GetDevices(_, _ string) []*podresourcesapi.ContainerDevices {
|
func (h *ManagerStub) GetDevices(_, _ string) []*podresourcesapi.ContainerDevices {
|
||||||
return nil
|
return nil
|
||||||
|
@ -80,6 +80,12 @@ func (m *ManagerImpl) GetTopologyHints(pod *v1.Pod, container *v1.Container) map
|
|||||||
return deviceHints
|
return deviceHints
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPodTopologyHints implements the TopologyManager HintProvider Interface which
|
||||||
|
// ensures the Device Manager is consulted when Topology Aware Hints for Pod are created.
|
||||||
|
func (m *ManagerImpl) GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
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 set, we assume they care about alignment.
|
||||||
for device := range m.allDevices[resource] {
|
for device := range m.allDevices[resource] {
|
||||||
|
@ -71,6 +71,10 @@ type Manager interface {
|
|||||||
// and is consulted to make Topology aware resource alignments
|
// and is consulted to make Topology aware resource alignments
|
||||||
GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint
|
GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint
|
||||||
|
|
||||||
|
// TopologyManager HintProvider provider indicates the Device Manager implements the Topology Manager Interface
|
||||||
|
// and is consulted to make Topology aware resource alignments per Pod
|
||||||
|
GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint
|
||||||
|
|
||||||
// UpdateAllocatedDevices frees any Devices that are bound to terminated pods.
|
// UpdateAllocatedDevices frees any Devices that are bound to terminated pods.
|
||||||
UpdateAllocatedDevices()
|
UpdateAllocatedDevices()
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,9 @@ type HintProvider interface {
|
|||||||
// a consensus "best" hint. The hint providers may subsequently query the
|
// a consensus "best" hint. The hint providers may subsequently query the
|
||||||
// topology manager to influence actual resource assignment.
|
// topology manager to influence actual resource assignment.
|
||||||
GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]TopologyHint
|
GetTopologyHints(pod *v1.Pod, container *v1.Container) map[string][]TopologyHint
|
||||||
|
// GetPodTopologyHints returns a map of resource names to a list of possible
|
||||||
|
// concrete resource allocations per Pod in terms of NUMA locality hints.
|
||||||
|
GetPodTopologyHints(pod *v1.Pod) map[string][]TopologyHint
|
||||||
// Allocate triggers resource allocation to occur on the HintProvider after
|
// Allocate triggers resource allocation to occur on the HintProvider after
|
||||||
// all hints have been gathered and the aggregated Hint is available via a
|
// all hints have been gathered and the aggregated Hint is available via a
|
||||||
// call to Store.GetAffinity().
|
// call to Store.GetAffinity().
|
||||||
|
@ -84,6 +84,10 @@ func (m *mockHintProvider) GetTopologyHints(pod *v1.Pod, container *v1.Container
|
|||||||
return m.th
|
return m.th
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mockHintProvider) GetPodTopologyHints(pod *v1.Pod) map[string][]TopologyHint {
|
||||||
|
return m.th
|
||||||
|
}
|
||||||
|
|
||||||
func (m *mockHintProvider) Allocate(pod *v1.Pod, container *v1.Container) error {
|
func (m *mockHintProvider) Allocate(pod *v1.Pod, container *v1.Container) error {
|
||||||
//return allocateError
|
//return allocateError
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user