Skip to content

Commit d1a35f6

Browse files
fix: update cpu share formula from runc 1.3.2 (#267)
Signed-off-by: Shubhranshu Mahapatra <[email protected]>
1 parent 7506952 commit d1a35f6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/run.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,11 @@ func Run(o *RunOption) {
601601
})
602602

603603
ginkgo.It("should set the CPU shares with --cpu-shares flag", func() {
604-
// CgroupV2 CPUShares => weight := 1 + ((shares-2)*9999)/262142
605-
//nolint: lll // the source of the CPUShares calculation formula
606-
// Ref. https://github.com/google/cadvisor/blob/ce07bb28eadc18183df15ca5346293af6b020b33/integration/tests/api/docker_test.go#L216-L222
604+
// CgroupV2 Formula: https://github.com/opencontainers/cgroups/blob/2f41057bdff0636deea1e50c551379c5c2e6a15f/utils.go#L425
605+
// Ref. https://github.com/opencontainers/runc/pull/4785
607606
cpuWeight := command.StdoutStr(o.BaseOpt, "run", "--rm", "--cpu-shares", "2000",
608607
"-w", "/sys/fs/cgroup", localImages[defaultImage], "cat", "cpu.weight")
609-
gomega.Expect(cpuWeight).To(gomega.Equal("77"))
608+
gomega.Expect(cpuWeight).To(gomega.Equal("170"))
610609
})
611610

612611
// assume the host has at least 2 CPUs

0 commit comments

Comments
 (0)