Revert "cgroups: only return path when subsystem really mounted"

This reverts commit 606d9064b0.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-03-23 12:14:03 -07:00
parent f8daab8a96
commit fc3981ea5c
6 changed files with 9 additions and 34 deletions

View File

@ -235,12 +235,6 @@ func (raw *data) parent(subsystem string) (string, error) {
}
func (raw *data) path(subsystem string) (string, error) {
_, err := cgroups.FindCgroupMountpoint(subsystem)
// If we didn't mount the subsystem, there is no point we make the path.
if err != nil {
return "", err
}
// If the cgroup name/path is absolute do not look relative to the cgroup of the init process.
if filepath.IsAbs(raw.cgroup) {
return filepath.Join(raw.root, subsystem, raw.cgroup), nil

View File

@ -17,13 +17,9 @@ type BlkioGroup struct {
func (s *BlkioGroup) Apply(d *data) error {
dir, err := d.join("blkio")
if err != nil {
if cgroups.IsNotFound(err) {
return nil
} else {
if err != nil && !cgroups.IsNotFound(err) {
return err
}
}
if err := s.Set(dir, d.c); err != nil {
return err

View File

@ -18,12 +18,8 @@ func (s *CpuGroup) Apply(d *data) error {
// on a container basis
dir, err := d.join("cpu")
if err != nil {
if cgroups.IsNotFound(err) {
return nil
} else {
return err
}
}
if err := s.Set(dir, d.c); err != nil {
return err

View File

@ -11,12 +11,8 @@ type DevicesGroup struct {
func (s *DevicesGroup) Apply(d *data) error {
dir, err := d.join("devices")
if err != nil {
if cgroups.IsNotFound(err) {
return nil
} else {
return err
}
}
if err := s.Set(dir, d.c); err != nil {
return err

View File

@ -13,13 +13,9 @@ type FreezerGroup struct {
func (s *FreezerGroup) Apply(d *data) error {
dir, err := d.join("freezer")
if err != nil {
if cgroups.IsNotFound(err) {
return nil
} else {
if err != nil && !cgroups.IsNotFound(err) {
return err
}
}
if err := s.Set(dir, d.c); err != nil {
return err

View File

@ -16,13 +16,10 @@ type MemoryGroup struct {
func (s *MemoryGroup) Apply(d *data) error {
dir, err := d.join("memory")
if err != nil {
if cgroups.IsNotFound(err) {
return nil
} else {
// only return an error for memory if it was specified
if err != nil && (d.c.Memory != 0 || d.c.MemoryReservation != 0 || d.c.MemorySwap != 0) {
return err
}
}
defer func() {
if err != nil {
os.RemoveAll(dir)