Merge pull request #2412 from lifubang/removecgpath
remove cgroup path recursively in cgroup v2
diff --git a/libcontainer/cgroups/systemd/v1.go b/libcontainer/cgroups/systemd/v1.go
index 5d32413..dda271a 100644
--- a/libcontainer/cgroups/systemd/v1.go
+++ b/libcontainer/cgroups/systemd/v1.go
@@ -4,7 +4,6 @@
import (
"errors"
- "fmt"
"io/ioutil"
"math"
"os"
@@ -90,18 +89,7 @@
}
// cpu.cfs_quota_us and cpu.cfs_period_us are controlled by systemd.
- if c.Resources.CpuQuota != 0 || c.Resources.CpuPeriod != 0 {
- if c.Resources.CpuQuota < -1 {
- return nil, fmt.Errorf("Invalid CPU quota value: %d", c.Resources.CpuQuota)
- }
- if c.Resources.CpuQuota != -1 {
- if c.Resources.CpuQuota == 0 || c.Resources.CpuPeriod == 0 {
- return nil, errors.New("CPU quota and period should both be set")
- }
- if c.Resources.CpuPeriod < 0 {
- return nil, fmt.Errorf("Invalid CPU period value: %d", c.Resources.CpuPeriod)
- }
- }
+ if c.Resources.CpuQuota != 0 && c.Resources.CpuPeriod != 0 {
// corresponds to USEC_INFINITY in systemd
// if USEC_INFINITY is provided, CPUQuota is left unbound by systemd
// always setting a property value ensures we can apply a quota and remove it later
diff --git a/tests/integration/update.bats b/tests/integration/update.bats
index 72ee610..4c1585e 100644
--- a/tests/integration/update.bats
+++ b/tests/integration/update.bats
@@ -281,6 +281,13 @@
[ "$status" -eq 0 ]
check_cgroup_value "cpu.cfs_quota_us" 600000
else
+ # update cpu quota
+ runc update test_update --cpu-quota 600000
+ [ "$status" -eq 0 ]
+ check_cgroup_value "cpu.cfs_quota_us" 600000
+ # this is currently broken
+ #check_systemd_value "CPUQuotaPerSecUSec" 600ms
+
# update cpu quota and period together
runc update test_update --cpu-period 900000 --cpu-quota 600000
[ "$status" -eq 0 ]