Skip to content

Commit

Permalink
Merge pull request openshift#80 from rjnagal/cgroup-cleanup
Browse files Browse the repository at this point in the history
Change checks for non-existent cgroup file to a more concise form.
  • Loading branch information
vmarmol committed Jul 9, 2014
2 parents 46e34cf + dceaa2e commit c427473
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cgroups/fs/blkio.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"strconv"
"strings"
"syscall"

"github.com/docker/libcontainer/cgroups"
)
Expand Down Expand Up @@ -66,7 +65,7 @@ func getBlkioStat(path string) ([]cgroups.BlkioStatEntry, error) {
var blkioStats []cgroups.BlkioStatEntry
f, err := os.Open(path)
if err != nil {
if pathErr, ok := err.(*os.PathError); ok && pathErr.Err == syscall.ENOENT {
if os.IsNotExist(err) {
return blkioStats, nil
}
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions cgroups/fs/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"path/filepath"
"strconv"
"syscall"

"github.com/docker/libcontainer/cgroups"
)
Expand Down Expand Up @@ -50,7 +49,7 @@ func (s *cpuGroup) GetStats(d *data, stats *cgroups.Stats) error {

f, err := os.Open(filepath.Join(path, "cpu.stat"))
if err != nil {
if pathErr, ok := err.(*os.PathError); ok && pathErr.Err == syscall.ENOENT {
if os.IsNotExist(err) {
return nil
}
return err
Expand Down
3 changes: 1 addition & 2 deletions cgroups/fs/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"path/filepath"
"strconv"
"syscall"

"github.com/docker/libcontainer/cgroups"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func (s *memoryGroup) GetStats(d *data, stats *cgroups.Stats) error {
// Set stats from memory.stat.
statsFile, err := os.Open(filepath.Join(path, "memory.stat"))
if err != nil {
if pathErr, ok := err.(*os.PathError); ok && pathErr.Err == syscall.ENOENT {
if os.IsNotExist(err) {
return nil
}
return err
Expand Down

0 comments on commit c427473

Please sign in to comment.