mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Update CPU manager GetCPUs method to return pointer to CPUSet
This commit is contained in:
@@ -1028,7 +1028,7 @@ func (cm *containerManagerImpl) GetDevices(podUID, containerName string) []*podr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cm *containerManagerImpl) GetCPUs(podUID, containerName string) []int64 {
|
func (cm *containerManagerImpl) GetCPUs(podUID, containerName string) []int64 {
|
||||||
return cm.cpuManager.GetCPUs(podUID, containerName)
|
return cm.cpuManager.GetCPUs(podUID, containerName).ToSliceNoSortInt64()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *containerManagerImpl) ShouldResetExtendedResourceCapacity() bool {
|
func (cm *containerManagerImpl) ShouldResetExtendedResourceCapacity() bool {
|
||||||
|
@@ -80,7 +80,7 @@ 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) cpuset.CPUSet
|
||||||
|
|
||||||
// GetPodTopologyHints implements the topologymanager.HintProvider Interface
|
// GetPodTopologyHints implements the topologymanager.HintProvider Interface
|
||||||
// and is consulted to achieve NUMA aware resource alignment per Pod
|
// and is consulted to achieve NUMA aware resource alignment per Pod
|
||||||
@@ -481,11 +481,6 @@ func (m *manager) updateContainerCPUSet(containerID string, cpus cpuset.CPUSet)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *manager) GetCPUs(podUID, containerName string) []int64 {
|
func (m *manager) GetCPUs(podUID, containerName string) cpuset.CPUSet {
|
||||||
cpus := m.state.GetCPUSetOrDefault(string(podUID), containerName)
|
return m.state.GetCPUSetOrDefault(podUID, containerName)
|
||||||
result := []int64{}
|
|
||||||
for _, cpu := range cpus.ToSliceNoSort() {
|
|
||||||
result = append(result, int64(cpu))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cm/containermap"
|
"k8s.io/kubernetes/pkg/kubelet/cm/containermap"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state"
|
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state"
|
||||||
|
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
|
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/status"
|
"k8s.io/kubernetes/pkg/kubelet/status"
|
||||||
@@ -69,9 +70,9 @@ func (m *fakeManager) State() state.Reader {
|
|||||||
return m.state
|
return m.state
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *fakeManager) GetCPUs(podUID, containerName string) []int64 {
|
func (m *fakeManager) GetCPUs(podUID, containerName string) cpuset.CPUSet {
|
||||||
klog.Infof("[fake cpumanager] GetCPUs(podUID: %s, containerName: %s)", podUID, containerName)
|
klog.Infof("[fake cpumanager] GetCPUs(podUID: %s, containerName: %s)", podUID, containerName)
|
||||||
return nil
|
return cpuset.CPUSet{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFakeManager creates empty/fake cpu manager
|
// NewFakeManager creates empty/fake cpu manager
|
||||||
|
Reference in New Issue
Block a user