Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions libcontainer/cgroups/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,12 @@ func (m *manager) Apply(pid int) (err error) {
return cgroups.ErrV1NoUnified
}

m.paths = make(map[string]string)
if c.Paths != nil {
cgMap, err := cgroups.ParseCgroupFile("/proc/self/cgroup")
if err != nil {
return err
}
for name, path := range c.Paths {
// XXX(kolyshkin@): why this check is needed?
if _, ok := cgMap[name]; ok {
m.paths[name] = path
}
}
return cgroups.EnterPid(m.paths, pid)
}

d, err := getCgroupData(m.cgroups, pid)
if err != nil {
return err
}

m.paths = make(map[string]string)
for _, sys := range subsystems {
p, err := d.path(sys.Name())
if err != nil {
Expand Down Expand Up @@ -245,9 +231,6 @@ func (m *manager) Apply(pid int) (err error) {
}

func (m *manager) Destroy() error {
if m.cgroups == nil || m.cgroups.Paths != nil {
return nil
}
m.mu.Lock()
defer m.mu.Unlock()
return cgroups.RemovePaths(m.paths)
Expand Down Expand Up @@ -280,11 +263,6 @@ func (m *manager) Set(r *configs.Resources) error {
return nil
}

// If Paths are set, then we are just joining cgroups paths
// and there is no need to set any values.
if m.cgroups != nil && m.cgroups.Paths != nil {
return nil
}
if r.Unified != nil {
return cgroups.ErrV1NoUnified
}
Expand Down
4 changes: 0 additions & 4 deletions libcontainer/cgroups/fs2/defaultpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ func defaultDirPath(c *configs.Cgroup) (string, error) {
if (c.Name != "" || c.Parent != "") && c.Path != "" {
return "", fmt.Errorf("cgroup: either Path or Name and Parent should be used, got %+v", c)
}
if len(c.Paths) != 0 {
// never set by specconv
return "", fmt.Errorf("cgroup: Paths is unsupported, use Path, got %+v", c)
}

// XXX: Do not remove this code. Path safety is important! -- cyphar
cgPath := libcontainerUtils.CleanPath(c.Path)
Expand Down
23 changes: 0 additions & 23 deletions libcontainer/cgroups/systemd/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,6 @@ func (m *legacyManager) Apply(pid int) error {

m.mu.Lock()
defer m.mu.Unlock()
if c.Paths != nil {
paths := make(map[string]string)
cgMap, err := cgroups.ParseCgroupFile("/proc/self/cgroup")
if err != nil {
return err
}
// XXX(kolyshkin@): why this check is needed?
for name, path := range c.Paths {
if _, ok := cgMap[name]; ok {
paths[name] = path
}
}
m.paths = paths
return cgroups.EnterPid(m.paths, pid)
}

if c.Parent != "" {
slice = c.Parent
Expand Down Expand Up @@ -201,9 +186,6 @@ func (m *legacyManager) Apply(pid int) error {
}

func (m *legacyManager) Destroy() error {
if m.cgroups.Paths != nil {
return nil
}
m.mu.Lock()
defer m.mu.Unlock()

Expand Down Expand Up @@ -388,11 +370,6 @@ func (m *legacyManager) freezeBeforeSet(unitName string, r *configs.Resources) (
}

func (m *legacyManager) Set(r *configs.Resources) error {
// If Paths are set, then we are just joining cgroups paths
// and there is no need to set any values.
if m.cgroups.Paths != nil {
return nil
}
if r.Unified != nil {
return cgroups.ErrV1NoUnified
}
Expand Down
7 changes: 0 additions & 7 deletions libcontainer/cgroups/systemd/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,6 @@ func (m *unifiedManager) Apply(pid int) error {
properties []systemdDbus.Property
)

if c.Paths != nil {
return cgroups.WriteCgroupProc(m.path, pid)
}

slice := "system.slice"
if m.rootless {
slice = "user.slice"
Expand Down Expand Up @@ -296,9 +292,6 @@ func (m *unifiedManager) Apply(pid int) error {
}

func (m *unifiedManager) Destroy() error {
if m.cgroups.Paths != nil {
return nil
}
m.mu.Lock()
defer m.mu.Unlock()

Expand Down
4 changes: 0 additions & 4 deletions libcontainer/configs/cgroup_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ type Cgroup struct {
// ScopePrefix describes prefix for the scope name
ScopePrefix string `json:"scope_prefix"`

// Paths represent the absolute cgroups paths to join.
// This takes precedence over Path.
Paths map[string]string

// Resources contains various cgroups settings to apply
*Resources

Expand Down