Repository: opencontainers/runc
File: libcontainer/cgroups/fs/cpu.go (Go)

Code before:
			// than the current one, it is rejected by the kernel
			// (EINVAL) as old_quota/new_period exceeds the parent
			// cgroup quota limit. If this happens and the quota is
			// going to be set, ignore the error for now and retry
			// after setting the quota.
			if !errors.Is(err, unix.EINVAL) || r.CpuQuota == 0 {
				return err
			}
		} else {
			period = ""
		}
	}

	var burst string
	if r.CpuBurst != 0 {
		burst = strconv.FormatUint(r.CpuBurst, 10)
		if err := cgroups.WriteFile(path, "cpu.cfs_burst_us", burst); err != nil {
			// Sometimes when the burst to be set is larger
			// than the current one, it is rejected by the kernel
			// (EINVAL) as old_quota/new_burst exceeds the parent
			// cgroup quota limit. If this happens and the quota is
			// going to be set, ignore the error for now and retry
			// after setting the quota.
			if !errors.Is(err, unix.ENOENT) {
				// this is a special trick for burst feature, the current systemd and low version of kernel will not support it.
				// So, an `no such file or directory` error would be raised, and we can ignore it .
				if !errors.Is(err, unix.EINVAL) || r.CpuQuota == 0 {
					return err
				}
			}
		} else {
			burst = ""
		}
	}
	if r.CpuQuota != 0 {
		if err := cgroups.WriteFile(path, "cpu.cfs_quota_us", strconv.FormatInt(r.CpuQuota, 10)); err != nil {
			return err
		}
		if period != "" {
			if err := cgroups.WriteFile(path, "cpu.cfs_period_us", period); err != nil {
				return err
			}
		}
		if burst != "" {
			if err := cgroups.WriteFile(path, "cpu.cfs_burst_us", burst); err != nil {
				return err
			}
		}
	}

	if r.CPUIdle != nil {

Review comment (suggestion):
I think these two lines comments is for `unix.ENOENT`, you should put the comments in the correct place, so please exchange the comments of `unix.ENOENT` and `unix.EINVAL`.

Code after:
			// than the current one, it is rejected by the kernel
			// (EINVAL) as old_quota/new_period exceeds the parent
			// cgroup quota limit. If this happens and the quota is
			// going to be set, ignore the error for now and retry
			// after setting the quota.
			if !errors.Is(err, unix.EINVAL) || r.CpuQuota == 0 {
				return err
			}
		} else {
			period = ""
		}
	}

	var burst string
	if r.CpuBurst != nil {
		burst = strconv.FormatUint(*r.CpuBurst, 10)
		if err := cgroups.WriteFile(path, "cpu.cfs_burst_us", burst); err != nil {
			// this is a special trick for burst feature, the current systemd and low version of kernel will not support it.
			// So, an `no such file or directory` error would be raised, and we can ignore it .
			if !errors.Is(err, unix.ENOENT) {
				// Sometimes when the burst to be set is larger
				// than the current one, it is rejected by the kernel
				// (EINVAL) as old_quota/new_burst exceeds the parent
				// cgroup quota limit. If this happens and the quota is
				// going to be set, ignore the error for now and retry
				// after setting the quota.
				if !errors.Is(err, unix.EINVAL) || r.CpuQuota == 0 {
					return err
				}
			}
		} else {
			burst = ""
		}
	}
	if r.CpuQuota != 0 {
		if err := cgroups.WriteFile(path, "cpu.cfs_quota_us", strconv.FormatInt(r.CpuQuota, 10)); err != nil {
			return err
		}
		if period != "" {
			if err := cgroups.WriteFile(path, "cpu.cfs_period_us", period); err != nil {
				return err
			}
		}
		if burst != "" {
			if err := cgroups.WriteFile(path, "cpu.cfs_burst_us", burst); err != nil {
				if !errors.Is(err, unix.ENOENT) {
					return err
				}
			}
		}
	}