container_create: set cpuset cpus|mems
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
6c0b79b706
commit
de0be63495
3 changed files with 38 additions and 23 deletions
|
@ -785,28 +785,13 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
||||||
if linux != nil {
|
if linux != nil {
|
||||||
resources := linux.GetResources()
|
resources := linux.GetResources()
|
||||||
if resources != nil {
|
if resources != nil {
|
||||||
cpuPeriod := resources.CpuPeriod
|
specgen.SetLinuxResourcesCPUPeriod(uint64(resources.GetCpuPeriod()))
|
||||||
if cpuPeriod != 0 {
|
specgen.SetLinuxResourcesCPUQuota(resources.GetCpuQuota())
|
||||||
specgen.SetLinuxResourcesCPUPeriod(uint64(cpuPeriod))
|
specgen.SetLinuxResourcesCPUShares(uint64(resources.GetCpuShares()))
|
||||||
}
|
specgen.SetLinuxResourcesMemoryLimit(resources.GetMemoryLimitInBytes())
|
||||||
|
specgen.SetProcessOOMScoreAdj(int(resources.GetOomScoreAdj()))
|
||||||
cpuQuota := resources.CpuQuota
|
specgen.SetLinuxResourcesCPUCpus(resources.GetCpusetCpus())
|
||||||
if cpuQuota != 0 {
|
specgen.SetLinuxResourcesCPUMems(resources.GetCpusetMems())
|
||||||
specgen.SetLinuxResourcesCPUQuota(cpuQuota)
|
|
||||||
}
|
|
||||||
|
|
||||||
cpuShares := resources.CpuShares
|
|
||||||
if cpuShares != 0 {
|
|
||||||
specgen.SetLinuxResourcesCPUShares(uint64(cpuShares))
|
|
||||||
}
|
|
||||||
|
|
||||||
memoryLimit := resources.MemoryLimitInBytes
|
|
||||||
if memoryLimit != 0 {
|
|
||||||
specgen.SetLinuxResourcesMemoryLimit(memoryLimit)
|
|
||||||
}
|
|
||||||
|
|
||||||
oomScoreAdj := resources.OomScoreAdj
|
|
||||||
specgen.SetProcessOOMScoreAdj(int(oomScoreAdj))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var cgPath string
|
var cgPath string
|
||||||
|
|
|
@ -1061,3 +1061,31 @@ function teardown() {
|
||||||
cleanup_pods
|
cleanup_pods
|
||||||
stop_crio
|
stop_crio
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "ctr resources" {
|
||||||
|
start_crio
|
||||||
|
run crictl runs "$TESTDATA"/sandbox_config.json
|
||||||
|
echo "$output"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
pod_id="$output"
|
||||||
|
run crictl create "$pod_id" "$TESTDATA"/container_redis.json "$TESTDATA"/sandbox_config.json
|
||||||
|
echo "$output"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
ctr_id="$output"
|
||||||
|
run crictl start "$ctr_id"
|
||||||
|
echo "$output"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
run crictl exec --sync "$ctr_id" sh -c "cat /sys/fs/cgroup/cpuset/cpuset.cpus"
|
||||||
|
echo "$output"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[[ "$output" =~ "0-1" ]]
|
||||||
|
run crictl exec --sync "$ctr_id" sh -c "cat /sys/fs/cgroup/cpuset/cpuset.mems"
|
||||||
|
echo "$output"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[[ "$output" =~ "0" ]]
|
||||||
|
|
||||||
|
cleanup_ctrs
|
||||||
|
cleanup_pods
|
||||||
|
stop_crio
|
||||||
|
}
|
||||||
|
|
4
test/testdata/container_redis.json
vendored
4
test/testdata/container_redis.json
vendored
|
@ -49,7 +49,9 @@
|
||||||
"cpu_period": 10000,
|
"cpu_period": 10000,
|
||||||
"cpu_quota": 20000,
|
"cpu_quota": 20000,
|
||||||
"cpu_shares": 512,
|
"cpu_shares": 512,
|
||||||
"oom_score_adj": 30
|
"oom_score_adj": 30,
|
||||||
|
"cpuset_cpus": "0-1",
|
||||||
|
"cpuset_mems": "0"
|
||||||
},
|
},
|
||||||
"security_context": {
|
"security_context": {
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
|
|
Loading…
Reference in a new issue