Skip to content

Commit

Permalink
Merge pull request #18992 from juanvallejo/jvallejo/cli-observe-1
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 18953, 18992).

ignore wait4 errs in observe max-err-count

Fixes #17743

These errors should not count against the --maximum-errors count
as the process has cleanly run and exited before wait4 syscall is made.

cc @smarterclayton @soltysh
  • Loading branch information
openshift-merge-robot authored Mar 19, 2018
2 parents 344a232 + 7565f7d commit 0706074
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/oc/cli/cmd/observe/observe.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,27 @@ func measureCommandDuration(m *prometheus.SummaryVec, fn func() error, labels ..
statusCode = -1
}
m.WithLabelValues(append(labels, strconv.Itoa(statusCode))...).Observe(float64(duration / time.Millisecond))

if errnoError(err) == syscall.ECHILD {
// ignore wait4 syscall errno as it means
// that the subprocess has started and ended
// before the wait call was made.
return nil
}

return err
}

func errnoError(err error) syscall.Errno {
if se, ok := err.(*os.SyscallError); ok {
if errno, ok := se.Err.(syscall.Errno); ok {
return errno
}
}

return 0
}

func exitCodeForCommandError(err error) (int, bool) {
if err == nil {
return 0, true
Expand Down

0 comments on commit 0706074

Please sign in to comment.