Skip to content

Commit

Permalink
Revert "cgroups: add pids controller support"
Browse files Browse the repository at this point in the history
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
  • Loading branch information
Mrunal Patel authored and mrunalp committed Dec 19, 2015
1 parent bc46574 commit 4124ba9
Show file tree
Hide file tree
Showing 22 changed files with 200 additions and 408 deletions.
20 changes: 3 additions & 17 deletions libcontainer/cgroups/fs/apply_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var (
&MemoryGroup{},
&CpuGroup{},
&CpuacctGroup{},
&PidsGroup{},
&BlkioGroup{},
&HugetlbGroup{},
&NetClsGroup{},
Expand Down Expand Up @@ -180,24 +179,11 @@ func (m *Manager) GetStats() (*cgroups.Stats, error) {
}

func (m *Manager) Set(container *configs.Config) error {
for _, sys := range subsystems {
// We can't set this here, because after being applied, memcg doesn't
// allow a non-empty cgroup from having its limits changed.
if sys.Name() == "memory" {
for name, path := range m.Paths {
sys, err := subsystems.Get(name)
if err == errSubsystemDoesNotExist || !cgroups.PathExists(path) {
continue
}

// Generate fake cgroup data.
d, err := getCgroupData(container.Cgroups, -1)
if err != nil {
return err
}
// Get the path, but don't error out if the cgroup wasn't found.
path, err := d.path(sys.Name())
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := sys.Set(path, container.Cgroups); err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/blkio.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ func (s *BlkioGroup) Name() string {
}

func (s *BlkioGroup) Apply(d *cgroupData) error {
_, err := d.join("blkio")
dir, err := d.join("blkio")
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ func (s *CpuGroup) Name() string {
func (s *CpuGroup) Apply(d *cgroupData) error {
// We always want to join the cpu group, to allow fair cpu scheduling
// on a container basis
_, err := d.join("cpu")
dir, err := d.join("cpu")
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions libcontainer/cgroups/fs/cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func (s *CpusetGroup) ApplyDir(dir string, cgroup *configs.Cgroup, pid int) erro
if err := s.ensureParent(dir, root); err != nil {
return err
}
// the default values inherit from parent cgroup are already set in
// s.ensureParent, cover these if we have our own
if err := s.Set(dir, cgroup); err != nil {
return err
}
// because we are not using d.join we need to place the pid into the procs file
// unlike the other subsystems
if err := writeFile(dir, "cgroup.procs", strconv.Itoa(pid)); err != nil {
Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ func (s *DevicesGroup) Name() string {
}

func (s *DevicesGroup) Apply(d *cgroupData) error {
_, err := d.join("devices")
dir, err := d.join("devices")
if err != nil {
// We will return error even it's `not found` error, devices
// cgroup is hard requirement for container's security.
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ func (s *FreezerGroup) Name() string {
}

func (s *FreezerGroup) Apply(d *cgroupData) error {
_, err := d.join("freezer")
dir, err := d.join("freezer")
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/hugetlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ func (s *HugetlbGroup) Name() string {
}

func (s *HugetlbGroup) Apply(d *cgroupData) error {
_, err := d.join("hugetlb")
dir, err := d.join("hugetlb")
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions libcontainer/cgroups/fs/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (s *MemoryGroup) Apply(d *cgroupData) (err error) {
return err
}
}

if err := s.Set(path, d.config); err != nil {
return err
}
Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/net_cls.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ func (s *NetClsGroup) Name() string {
}

func (s *NetClsGroup) Apply(d *cgroupData) error {
_, err := d.join("net_cls")
dir, err := d.join("net_cls")
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
7 changes: 6 additions & 1 deletion libcontainer/cgroups/fs/net_prio.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ func (s *NetPrioGroup) Name() string {
}

func (s *NetPrioGroup) Apply(d *cgroupData) error {
_, err := d.join("net_prio")
dir, err := d.join("net_prio")
if err != nil && !cgroups.IsNotFound(err) {
return err
}

if err := s.Set(dir, d.config); err != nil {
return err
}

return nil
}

Expand Down
57 changes: 0 additions & 57 deletions libcontainer/cgroups/fs/pids.go

This file was deleted.

83 changes: 0 additions & 83 deletions libcontainer/cgroups/fs/pids_test.go

This file was deleted.

6 changes: 0 additions & 6 deletions libcontainer/cgroups/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ type MemoryStats struct {
Stats map[string]uint64 `json:"stats,omitempty"`
}

type PidsStats struct {
// number of pids in the cgroup
Current uint64 `json:"current,omitempty"`
}

type BlkioStatEntry struct {
Major uint64 `json:"major,omitempty"`
Minor uint64 `json:"minor,omitempty"`
Expand Down Expand Up @@ -85,7 +80,6 @@ type HugetlbStats struct {
type Stats struct {
CpuStats CpuStats `json:"cpu_stats,omitempty"`
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
PidsStats PidsStats `json:"pids_stats,omitempty"`
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
// the map is in the format "size of hugepage: stats of the hugepage"
HugetlbStats map[string]HugetlbStats `json:"hugetlb_stats,omitempty"`
Expand Down
Loading

0 comments on commit 4124ba9

Please sign in to comment.