From 79c23fdbf4ab5aea2170c7bc6762e24c44eb84e0 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Thu, 17 Dec 2015 12:35:24 -0500 Subject: [PATCH] Don't log EPIPE errors on client download abort Signed-off-by: Brian Goff --- daemon/daemon.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index f858e73dd2..c2d453912e 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -10,11 +10,13 @@ import ( "fmt" "io" "io/ioutil" + "net" "os" "path/filepath" "runtime" "strings" "sync" + "syscall" "time" "github.com/Sirupsen/logrus" @@ -1047,7 +1049,12 @@ func writeDistributionProgress(cancelFunc func(), outStream io.Writer, progressC for prog := range progressChan { if err := progressOutput.WriteProgress(prog); err != nil && !operationCancelled { - logrus.Errorf("error writing progress to client: %v", err) + // 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) + } cancelFunc() operationCancelled = true // Don't return, because we need to continue draining @@ -1056,6 +1063,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 // 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 {