diff --git a/.changelog/11287.txt b/.changelog/11287.txt new file mode 100644 index 00000000000..36e6f7873c6 --- /dev/null +++ b/.changelog/11287.txt @@ -0,0 +1,4 @@ + +```release-note:bug +driver/exec: Set CPU resource limits when cgroup-v2 is enabled +``` diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index 54be7ed79f7..123284ceda5 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -696,8 +696,9 @@ func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error { return fmt.Errorf("resources.Cpu.CpuShares must be equal to or greater than 2: %v", cpuShares) } - // Set the relative CPU shares for this cgroup. + // Set the relative CPU shares for this cgroup, and convert for cgroupv2 cfg.Cgroups.Resources.CpuShares = uint64(cpuShares) + cfg.Cgroups.Resources.CpuWeight = cgroups.ConvertCPUSharesToCgroupV2Value(uint64(cpuShares)) if command.Resources.LinuxResources != nil && command.Resources.LinuxResources.CpusetCgroupPath != "" { cfg.Hooks = lconfigs.Hooks{