From 5b7e96219f8afbb54b0462ace066fa4ac76e7abb Mon Sep 17 00:00:00 2001 From: Sergey Kanzhelev Date: Fri, 3 Oct 2025 22:50:07 +0000 Subject: [PATCH] remove cpuSharesToCPUWeight that is not used any longer --- pkg/kubelet/cm/cgroup_manager_linux_test.go | 43 --------------------- pkg/kubelet/cm/cgroup_v2_manager_linux.go | 6 --- 2 files changed, 49 deletions(-) diff --git a/pkg/kubelet/cm/cgroup_manager_linux_test.go b/pkg/kubelet/cm/cgroup_manager_linux_test.go index 2974b5bc51f..2388d4da20c 100644 --- a/pkg/kubelet/cm/cgroup_manager_linux_test.go +++ b/pkg/kubelet/cm/cgroup_manager_linux_test.go @@ -170,49 +170,6 @@ func TestParseSystemdToCgroupName(t *testing.T) { } } -func TestCpuSharesToCPUWeight(t *testing.T) { - testCases := []struct { - cpuShares uint64 - expectedCpuWeight uint64 - }{ - { - cpuShares: 2, - expectedCpuWeight: 1, - }, - { - cpuShares: 3, - expectedCpuWeight: 1, - }, - { - cpuShares: 4, - expectedCpuWeight: 1, - }, - { - cpuShares: 28, - expectedCpuWeight: 1, - }, - { - cpuShares: 29, - expectedCpuWeight: 2, - }, - { - cpuShares: 245, - expectedCpuWeight: 10, - }, - { - cpuShares: 262144, - expectedCpuWeight: 10000, - }, - } - - for _, testCase := range testCases { - if actual := cpuSharesToCPUWeight(testCase.cpuShares); actual != testCase.expectedCpuWeight { - t.Errorf("cpuShares: %v, expectedCpuWeight: %v, actualCpuWeight: %v", - testCase.cpuShares, testCase.expectedCpuWeight, actual) - } - } -} - func TestCpuWeightToCPUShares(t *testing.T) { testCases := []struct { cpuWeight uint64 diff --git a/pkg/kubelet/cm/cgroup_v2_manager_linux.go b/pkg/kubelet/cm/cgroup_v2_manager_linux.go index 84f7b01c591..9acf4b0dd81 100644 --- a/pkg/kubelet/cm/cgroup_v2_manager_linux.go +++ b/pkg/kubelet/cm/cgroup_v2_manager_linux.go @@ -168,12 +168,6 @@ func (c *cgroupV2impl) buildCgroupUnifiedPath(name CgroupName) string { return path.Join(cmutil.CgroupRoot, cgroupFsAdaptedName) } -// Convert cgroup v1 cpu.shares value to cgroup v2 cpu.weight -// https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2254-cgroup-v2#phase-1-convert-from-cgroups-v1-settings-to-v2 -func cpuSharesToCPUWeight(cpuShares uint64) uint64 { - return uint64((((cpuShares - 2) * 9999) / 262142) + 1) -} - // Convert cgroup v2 cpu.weight value to cgroup v1 cpu.shares // https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2254-cgroup-v2#phase-1-convert-from-cgroups-v1-settings-to-v2 func cpuWeightToCPUShares(cpuWeight uint64) uint64 {