SetContainerQuota writes a quota to its correct location for the inner container. HACK: until https://github.com/nestybox/sysbox/issues/582 is resolved, we need to copy the CPU quota and period from the outer container to the inner container to ensure that applications inside the container know how
(ctx context.Context, containerID string, quota xunix.CPUQuota)
| 143 | // - /sys/fs/cgroup/cpu,cpuacct/<subpath>/syscont-cgroup-root/cpu.cfs_quota_us |
| 144 | // - /sys/fs/cgroup/cpu,cpuacct/<subpath>/syscont-cgroup-root/cpu.cfs_period_us |
| 145 | func SetContainerQuota(ctx context.Context, containerID string, quota xunix.CPUQuota) error { |
| 146 | switch quota.CGroup { |
| 147 | case xunix.CGroupV2: |
| 148 | return setContainerQuotaCGroupV2(ctx, containerID, quota) |
| 149 | case xunix.CGroupV1: |
| 150 | return setContainerQuotaCGroupV1(ctx, containerID, quota) |
| 151 | default: |
| 152 | return xerrors.Errorf("Unknown cgroup %d", quota.CGroup) |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func setContainerQuotaCGroupV2(ctx context.Context, containerID string, quota xunix.CPUQuota) error { |
| 157 | var ( |