mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
Merge pull request #137355 from lukaszwojciechowski/fix-cpuset-creation
cpumanager: Replace cpuset.CPUSet{} with cpuset.New() for proper initialization
This commit is contained in:
commit
bd3c97fbd8
7 changed files with 17 additions and 18 deletions
|
|
@ -536,8 +536,7 @@ func (m *manager) GetExclusiveCPUs(podUID, containerName string) cpuset.CPUSet {
|
|||
if result, ok := m.state.GetCPUSet(podUID, containerName); ok {
|
||||
return result
|
||||
}
|
||||
|
||||
return cpuset.CPUSet{}
|
||||
return cpuset.New()
|
||||
}
|
||||
|
||||
func (m *manager) GetCPUAffinity(podUID, containerName string) cpuset.CPUSet {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func (s *mockState) Delete(podUID string, containerName string) {
|
|||
}
|
||||
|
||||
func (s *mockState) ClearState() {
|
||||
s.defaultCPUSet = cpuset.CPUSet{}
|
||||
s.defaultCPUSet = cpuset.New()
|
||||
s.assignments = make(state.ContainerCPUAssignments)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,22 +80,22 @@ func (m *fakeManager) State() state.Reader {
|
|||
|
||||
func (m *fakeManager) GetExclusiveCPUs(podUID, containerName string) cpuset.CPUSet {
|
||||
m.logger.Info("GetExclusiveCPUs", "podUID", podUID, "containerName", containerName)
|
||||
return cpuset.CPUSet{}
|
||||
return cpuset.New()
|
||||
}
|
||||
|
||||
func (m *fakeManager) GetAllocatableCPUs() cpuset.CPUSet {
|
||||
m.logger.Info("Get Allocatable CPUs")
|
||||
return cpuset.CPUSet{}
|
||||
return cpuset.New()
|
||||
}
|
||||
|
||||
func (m *fakeManager) GetCPUAffinity(podUID, containerName string) cpuset.CPUSet {
|
||||
m.logger.Info("GetCPUAffinity", "podUID", podUID, "containerName", containerName)
|
||||
return cpuset.CPUSet{}
|
||||
return cpuset.New()
|
||||
}
|
||||
|
||||
func (m *fakeManager) GetAllCPUs() cpuset.CPUSet {
|
||||
m.logger.Info("GetAllCPUs")
|
||||
return cpuset.CPUSet{}
|
||||
return cpuset.New()
|
||||
}
|
||||
|
||||
// NewFakeManager creates empty/fake cpu manager
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ func (p *staticPolicy) GetTopologyHints(logger logr.Logger, s state.State, pod *
|
|||
}
|
||||
logger.Info("Regenerating TopologyHints for CPUs already allocated")
|
||||
return map[string][]topologymanager.TopologyHint{
|
||||
string(v1.ResourceCPU): p.generateCPUTopologyHints(allocated, cpuset.CPUSet{}, requested),
|
||||
string(v1.ResourceCPU): p.generateCPUTopologyHints(allocated, cpuset.New(), requested),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -646,7 +646,7 @@ func (p *staticPolicy) GetPodTopologyHints(logger logr.Logger, s state.State, po
|
|||
if assignedCPUs.Size() == requested {
|
||||
logger.Info("Regenerating TopologyHints for CPUs already allocated")
|
||||
return map[string][]topologymanager.TopologyHint{
|
||||
string(v1.ResourceCPU): p.generateCPUTopologyHints(assignedCPUs, cpuset.CPUSet{}, requested),
|
||||
string(v1.ResourceCPU): p.generateCPUTopologyHints(assignedCPUs, cpuset.New(), requested),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func (s *stateMemory) ClearState() {
|
|||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
s.defaultCPUSet = cpuset.CPUSet{}
|
||||
s.defaultCPUSet = cpuset.New()
|
||||
s.assignments = make(ContainerCPUAssignments)
|
||||
s.logger.V(2).Info("Cleared state")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ var _ = SIGDescribe("CPU Manager", ginkgo.Ordered, ginkgo.ContinueOnFailure, fra
|
|||
ginkgo.It("should let the container access all the online CPUs without a reserved CPUs set", func(ctx context.Context) {
|
||||
updateKubeletConfigIfNeeded(ctx, f, configureCPUManagerInKubelet(oldCfg, &cpuManagerKubeletArguments{
|
||||
policyName: string(cpumanager.PolicyStatic),
|
||||
reservedSystemCPUs: cpuset.CPUSet{},
|
||||
reservedSystemCPUs: cpuset.New(),
|
||||
}))
|
||||
|
||||
pod := makeCPUManagerPod("non-gu-pod", []ctnAttribute{
|
||||
|
|
@ -827,7 +827,7 @@ var _ = SIGDescribe("CPU Manager", ginkgo.Ordered, ginkgo.ContinueOnFailure, fra
|
|||
ginkgo.It("should let the container access all the online CPUs without a reserved CPUs set", func(ctx context.Context) {
|
||||
updateKubeletConfigIfNeeded(ctx, f, configureCPUManagerInKubelet(oldCfg, &cpuManagerKubeletArguments{
|
||||
policyName: string(cpumanager.PolicyStatic),
|
||||
reservedSystemCPUs: cpuset.CPUSet{},
|
||||
reservedSystemCPUs: cpuset.New(),
|
||||
enableCPUManagerOptions: true,
|
||||
options: map[string]string{
|
||||
cpumanager.StrictCPUReservationOption: "true",
|
||||
|
|
@ -2034,7 +2034,7 @@ var _ = SIGDescribe("CPU Manager Incompatibility Pod Level Resources", ginkgo.Or
|
|||
ginkgo.It("should let the container access all the online CPUs without a reserved CPUs set", func(ctx context.Context) {
|
||||
updateKubeletConfigIfNeeded(ctx, f, configureCPUManagerInKubelet(oldCfg, &cpuManagerKubeletArguments{
|
||||
policyName: string(cpumanager.PolicyStatic),
|
||||
reservedSystemCPUs: cpuset.CPUSet{},
|
||||
reservedSystemCPUs: cpuset.New(),
|
||||
enablePodLevelResources: true,
|
||||
}))
|
||||
|
||||
|
|
@ -2428,13 +2428,13 @@ func computeNUMADistribution(allocatedCPUs cpuset.CPUSet) map[int]int {
|
|||
func getContainerAllowedCPUs(pod *v1.Pod, ctnName string, isInit bool) (cpuset.CPUSet, error) {
|
||||
cgPath, err := makeCgroupPathForContainer(pod, ctnName, isInit, e2enodeCgroupV2Enabled)
|
||||
if err != nil {
|
||||
return cpuset.CPUSet{}, err
|
||||
return cpuset.New(), err
|
||||
}
|
||||
cgPath = filepath.Join(cgPath, cpusetFileNameFromVersion(e2enodeCgroupV2Enabled))
|
||||
framework.Logf("pod %s/%s cnt %s qos=%s path %q", pod.Namespace, pod.Name, ctnName, pod.Status.QOSClass, cgPath)
|
||||
data, err := os.ReadFile(cgPath)
|
||||
if err != nil {
|
||||
return cpuset.CPUSet{}, err
|
||||
return cpuset.New(), err
|
||||
}
|
||||
cpus := strings.TrimSpace(string(data))
|
||||
framework.Logf("pod %s/%s cnt %s cpuset %q", pod.Namespace, pod.Name, ctnName, cpus)
|
||||
|
|
|
|||
|
|
@ -1181,7 +1181,7 @@ var _ = SIGDescribe("POD Resources API", framework.WithSerial(), feature.PodReso
|
|||
|
||||
// intentionally passing empty cpuset instead of onlineCPUs because with none policy
|
||||
// we should get no allocatable cpus - no exclusively allocatable CPUs, depends on policy static
|
||||
podresourcesGetAllocatableResourcesTests(ctx, cli, sd, cpuset.CPUSet{}, cpuset.CPUSet{})
|
||||
podresourcesGetAllocatableResourcesTests(ctx, cli, sd, cpuset.New(), cpuset.New())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -1285,7 +1285,7 @@ var _ = SIGDescribe("POD Resources API", framework.WithSerial(), feature.PodReso
|
|||
|
||||
// intentionally passing empty cpuset instead of onlineCPUs because with none policy
|
||||
// we should get no allocatable cpus - no exclusively allocatable CPUs, depends on policy static
|
||||
podresourcesGetAllocatableResourcesTests(ctx, cli, nil, cpuset.CPUSet{}, cpuset.CPUSet{})
|
||||
podresourcesGetAllocatableResourcesTests(ctx, cli, nil, cpuset.New(), cpuset.New())
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -2062,7 +2062,7 @@ func requireLackOfSRIOVDevices() {
|
|||
func getOnlineCPUs() (cpuset.CPUSet, error) {
|
||||
onlineCPUList, err := os.ReadFile("/sys/devices/system/cpu/online")
|
||||
if err != nil {
|
||||
return cpuset.CPUSet{}, err
|
||||
return cpuset.New(), err
|
||||
}
|
||||
return cpuset.Parse(strings.TrimSpace(string(onlineCPUList)))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue