Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroup2: v2 subsystems should not call WriteCgroupProc() #2157

Closed
AkihiroSuda opened this issue Oct 26, 2019 · 0 comments · Fixed by #2169
Closed

cgroup2: v2 subsystems should not call WriteCgroupProc() #2157

AkihiroSuda opened this issue Oct 26, 2019 · 0 comments · Fixed by #2169

Comments

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Oct 26, 2019

func (s *CpuGroupV2) ApplyDir(path string, cgroup *configs.Cgroup, pid int) error {
// This might happen if we have no cpu cgroup mounted.
// Just do nothing and don't fail.
if path == "" {
return nil
}
if err := os.MkdirAll(path, 0755); err != nil {
return err
}
return cgroups.WriteCgroupProc(path, pid)
}

v2 subsystems should not call WriteCgroupProc(), because it should be managed by Manager rather than each of subsystems for unified mode

#2148 (comment)

The subsystem interface should be modified like this:

diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go
index 512fd700..66ab43ec 100644
--- a/libcontainer/cgroups/fs/apply_raw.go
+++ b/libcontainer/cgroups/fs/apply_raw.go
@@ -58,20 +58,24 @@ func (s subsystemSet) Get(name string) (subsystem, error) {
 }
 
 type subsystem interface {
        // Name returns the name of the subsystem.
        Name() string
        // Returns the stats, as 'stats', corresponding to the cgroup under 'path'.
        GetStats(path string, stats *cgroups.Stats) error
+       // Set the cgroup represented by cgroup.
+       Set(path string, cgroup *configs.Cgroup) error
+}
+
+type subsystemV1 interface {
+       subsystem
        // Removes the cgroup represented by 'cgroupData'.
        Remove(*cgroupData) error
        // Creates and joins the cgroup represented by 'cgroupData'.
        Apply(*cgroupData) error
-       // Set the cgroup represented by cgroup.
-       Set(path string, cgroup *configs.Cgroup) error
 }
 
 type Manager struct {
        mu       sync.Mutex
        Cgroups  *configs.Cgroup
        Rootless bool // ignore permission-related errors
        Paths    map[string]string
AkihiroSuda added a commit to AkihiroSuda/runc that referenced this issue Nov 7, 2019
split fs2 package from fs, as mixing up fs and fs2 is very likely to result in
unmaintainable code.

Inspired by containerd/cgroups#109

Fix opencontainers#2157

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
AkihiroSuda added a commit to AkihiroSuda/runc that referenced this issue Dec 6, 2019
split fs2 package from fs, as mixing up fs and fs2 is very likely to result in
unmaintainable code.

Inspired by containerd/cgroups#109

Fix opencontainers#2157

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
AkihiroSuda added a commit to AkihiroSuda/runc that referenced this issue Dec 6, 2019
split fs2 package from fs, as mixing up fs and fs2 is very likely to result in
unmaintainable code.

Inspired by containerd/cgroups#109

Fix opencontainers#2157

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
AkihiroSuda added a commit to AkihiroSuda/runc that referenced this issue Dec 6, 2019
split fs2 package from fs, as mixing up fs and fs2 is very likely to result in
unmaintainable code.

Inspired by containerd/cgroups#109

Fix opencontainers#2157

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
adrianreber pushed a commit to adrianreber/runc that referenced this issue Feb 10, 2020
split fs2 package from fs, as mixing up fs and fs2 is very likely to result in
unmaintainable code.

Inspired by containerd/cgroups#109

Fix opencontainers#2157

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant