The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3010
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 0cd61ff147e3853f8fcfa18e7a0fcc11b0688ced Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Thu, 13 Oct 2016 19:17:17 -0600 Subject: [PATCH] Log errors from `lxd netcat` to a temp file Hopefully this will help with debugging. Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- lxd/main_netcat.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lxd/main_netcat.go b/lxd/main_netcat.go index f5be1b3..00833f8 100644 --- a/lxd/main_netcat.go +++ b/lxd/main_netcat.go @@ -3,11 +3,26 @@ package main import ( "fmt" "io" + "io/ioutil" "net" "os" "sync" ) +type logErrorReader struct { + r io.Reader + f *os.File +} + +func (le logErrorReader) Read(p []byte) (int, error) { + n, err := le.r.Read(p) + if err != nil { + fmt.Fprintf(le.f, "Error reading netcat stream: %v", err) + } + + return n, err +} + // Netcat is called with: // // lxd netcat /path/to/unix/socket @@ -20,6 +35,12 @@ func cmdNetcat(args []string) error { return fmt.Errorf("Bad arguments %q", args) } + f, err := ioutil.TempFile("", "lxd_netcat_") + if err != nil { + return err + } + defer f.Close() + uAddr, err := net.ResolveUnixAddr("unix", args[1]) if err != nil { return err @@ -34,13 +55,19 @@ func cmdNetcat(args []string) error { wg.Add(1) go func() { - io.Copy(os.Stdout, conn) + _, err := io.Copy(os.Stdout, logErrorReader{conn, f}) + if err != nil { + fmt.Fprintf(f, "Error netcatting to stdout: %v", err) + } conn.Close() wg.Done() }() go func() { - io.Copy(conn, os.Stdin) + _, err := io.Copy(conn, os.Stdin) + if err != nil { + fmt.Fprintf(f, "Error netcatting to stdout: %v", err) + } }() wg.Wait()
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel