mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #18752 from cpuguy83/fix_broken_pipe_error_on_download_abrt
Don't log EPIPE errors on client download abort
This commit is contained in:
commit
b4e26a96da
1 changed files with 18 additions and 1 deletions
|
@ -10,11 +10,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
@ -1032,7 +1034,12 @@ func writeDistributionProgress(cancelFunc func(), outStream io.Writer, progressC
|
||||||
|
|
||||||
for prog := range progressChan {
|
for prog := range progressChan {
|
||||||
if err := progressOutput.WriteProgress(prog); err != nil && !operationCancelled {
|
if err := progressOutput.WriteProgress(prog); err != nil && !operationCancelled {
|
||||||
|
// don't log broken pipe errors as this is the normal case when a client aborts
|
||||||
|
if isBrokenPipe(err) {
|
||||||
|
logrus.Info("Pull session cancelled")
|
||||||
|
} else {
|
||||||
logrus.Errorf("error writing progress to client: %v", err)
|
logrus.Errorf("error writing progress to client: %v", err)
|
||||||
|
}
|
||||||
cancelFunc()
|
cancelFunc()
|
||||||
operationCancelled = true
|
operationCancelled = true
|
||||||
// Don't return, because we need to continue draining
|
// Don't return, because we need to continue draining
|
||||||
|
@ -1041,6 +1048,16 @@ func writeDistributionProgress(cancelFunc func(), outStream io.Writer, progressC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isBrokenPipe(e error) bool {
|
||||||
|
if netErr, ok := e.(*net.OpError); ok {
|
||||||
|
e = netErr.Err
|
||||||
|
if sysErr, ok := netErr.Err.(*os.SyscallError); ok {
|
||||||
|
e = sysErr.Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return e == syscall.EPIPE
|
||||||
|
}
|
||||||
|
|
||||||
// PullImage initiates a pull operation. image is the repository name to pull, and
|
// PullImage initiates a pull operation. image is the repository name to pull, and
|
||||||
// tag may be either empty, or indicate a specific tag to pull.
|
// tag may be either empty, or indicate a specific tag to pull.
|
||||||
func (daemon *Daemon) PullImage(ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
|
func (daemon *Daemon) PullImage(ref reference.Named, metaHeaders map[string][]string, authConfig *types.AuthConfig, outStream io.Writer) error {
|
||||||
|
|
Loading…
Reference in a new issue