Skip to content

Commit

Permalink
v2: flip error handling for readKVStat("memory.events") to reduce ind…
Browse files Browse the repository at this point in the history
…entation

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
  • Loading branch information
jepio committed Jan 31, 2022
1 parent 6a46df2 commit cf1f978
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,20 +660,19 @@ func (c *Manager) waitForEvents(ec chan<- Event, errCh chan<- error) {
}
if bytesRead >= syscall.SizeofInotifyEvent {
out := make(map[string]interface{})
if err := readKVStatsFile(c.path, "memory.events", out); err == nil {
e, err := parseMemoryEvents(out)
if err != nil {
errCh <- err
return
}
ec <- e
} else {
if err := readKVStatsFile(c.path, "memory.events", out); err != nil {
// When cgroup is deleted read may return -ENODEV instead of -ENOENT from open.
if _, statErr := os.Lstat(filepath.Join(c.path, "memory.events")); !os.IsNotExist(statErr) {
errCh <- err
}
return
}
e, err := parseMemoryEvents(out)
if err != nil {
errCh <- err
return
}
ec <- e
if c.isCgroupEmpty() {
return
}
Expand Down

0 comments on commit cf1f978

Please sign in to comment.