Skip to content

When runc updates the values ​​of cpu-rt-period and cpu-rt-runtime synchronously, an error occurs. #4094

@zhongTao99

Description

@zhongTao99

Description

For example:

  1. When the updated cpu-rt-runtime value becomes smaller and the cpu-rt-period value also becomes smaller, the update is unsuccessful.
    (1)when creating a container, set the parameters to: --cpu-rt-runtime 950000 --cpu-rt-period 1000000.
    (2)If the update parameters are --cpu-rt-runtime 5000 --cpu-rt-period 960000, runc cannot successfully updated。It will report an error: Invalid parameter

The reason is that in the SetRtSched function of runc, the cpu-rt-period value is written first and then the cpu-rt-runtime value. If the cpu-rt-period value is written without complying with the cgroup rules, an error will be reported and returned directly.

func (s *CpuGroup) SetRtSched(path string, r *configs.Resources) error {
	if r.CpuRtPeriod != 0 {
		if err := cgroups.WriteFile(path, "cpu.rt_period_us", strconv.FormatUint(r.CpuRtPeriod, 10)); err != nil {
			return err
		}
	}
	if r.CpuRtRuntime != 0 {
		if err := cgroups.WriteFile(path, "cpu.rt_runtime_us", strconv.FormatInt(r.CpuRtRuntime, 10)); err != nil {
			return err
		}
	}
	return nil
}

Describe the results you received and expected

runc successfully updated

What version of runc are you using?

runc version 1.1.3
commit: v1.1.3-0-g6724737f-dirty
spec: 1.0.2-dev
go: go1.20.8
libseccomp: 2.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions