Skip to content

Commit

Permalink
libcontainer: add method to get cgroup config from cgroup Manager
Browse files Browse the repository at this point in the history
Add method to get cgroup configuration from cgroup Manager to allow other
packages and aplications save it in disk.

fixes #2176

Signed-off-by: Julio Montes <julio.montes@intel.com>
  • Loading branch information
Julio Montes committed Dec 6, 2019
1 parent d0453ee commit 70ed2ca
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libcontainer/cgroups/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type Manager interface {

// Sets the cgroup as configured.
Set(container *configs.Config) error

// Gets the cgroup as configured.
GetCgroups() (*configs.Cgroup, error)
}

type NotFoundError struct {
Expand Down
4 changes: 4 additions & 0 deletions libcontainer/cgroups/fs/apply_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,7 @@ func CheckCpushares(path string, c uint64) error {

return nil
}

func (m *Manager) GetCgroups() (*configs.Cgroup, error) {
return m.Cgroups, nil
}
4 changes: 4 additions & 0 deletions libcontainer/cgroups/systemd/apply_nosystemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
func Freeze(c *configs.Cgroup, state configs.FreezerState) error {
return fmt.Errorf("Systemd not supported")
}

func (m *Manager) GetCgroups() (*configs.Cgroup, error) {
return nil, fmt.Errorf("Systemd not supported")
}
4 changes: 4 additions & 0 deletions libcontainer/cgroups/systemd/apply_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,7 @@ func isUnitExists(err error) bool {
}
return false
}

func (m *LegacyManager) GetCgroups() (*configs.Cgroup, error) {
return m.Cgroups, nil
}
4 changes: 4 additions & 0 deletions libcontainer/cgroups/systemd/unified_hierarchy.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,7 @@ func (m *UnifiedManager) Set(container *configs.Config) error {
}
return nil
}

func (m *UnifiedManager) GetCgroups() (*configs.Cgroup, error) {
return m.Cgroups, nil
}

0 comments on commit 70ed2ca

Please sign in to comment.