cgroups.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // +build linux
  2. package cgroups
  3. import (
  4. "github.com/opencontainers/runc/libcontainer/configs"
  5. )
  6. type Manager interface {
  7. // Applies cgroup configuration to the process with the specified pid
  8. Apply(pid int) error
  9. // Returns the PIDs inside the cgroup set
  10. GetPids() ([]int, error)
  11. // Returns the PIDs inside the cgroup set & all sub-cgroups
  12. GetAllPids() ([]int, error)
  13. // Returns statistics for the cgroup set
  14. GetStats() (*Stats, error)
  15. // Toggles the freezer cgroup according with specified state
  16. Freeze(state configs.FreezerState) error
  17. // Destroys the cgroup set
  18. Destroy() error
  19. // Path returns a cgroup path to the specified controller/subsystem.
  20. // For cgroupv2, the argument is unused and can be empty.
  21. Path(string) string
  22. // Sets the cgroup as configured.
  23. Set(container *configs.Config) error
  24. // GetPaths returns cgroup path(s) to save in a state file in order to restore later.
  25. //
  26. // For cgroup v1, a key is cgroup subsystem name, and the value is the path
  27. // to the cgroup for this subsystem.
  28. //
  29. // For cgroup v2 unified hierarchy, a key is "", and the value is the unified path.
  30. GetPaths() map[string]string
  31. // GetCgroups returns the cgroup data as configured.
  32. GetCgroups() (*configs.Cgroup, error)
  33. // GetFreezerState retrieves the current FreezerState of the cgroup.
  34. GetFreezerState() (configs.FreezerState, error)
  35. // Whether the cgroup path exists or not
  36. Exists() bool
  37. }