Browse code

Revendor Microsoft/opengcs @ v0.3.5

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2018/01/19 10:52:40
Showing 5 changed files
... ...
@@ -7,7 +7,7 @@ github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
7 7
 github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
8 8
 github.com/gorilla/context v1.1
9 9
 github.com/gorilla/mux v1.1
10
-github.com/Microsoft/opengcs v0.3.4
10
+github.com/Microsoft/opengcs v0.3.5
11 11
 github.com/kr/pty 5cf931ef8f
12 12
 github.com/mattn/go-shellwords v1.0.3
13 13
 github.com/sirupsen/logrus v1.0.3
14 14
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+// +build windows
1
+
2
+package client
3
+
4
+import (
5
+	"os"
6
+	"strconv"
7
+)
8
+
9
+var (
10
+	logDataFromUVM int64
11
+)
12
+
13
+func init() {
14
+	bytes := os.Getenv("OPENGCS_LOG_DATA_FROM_UVM")
15
+	if len(bytes) == 0 {
16
+		return
17
+	}
18
+	u, err := strconv.ParseUint(bytes, 10, 32)
19
+	if err != nil {
20
+		return
21
+	}
22
+	logDataFromUVM = int64(u)
23
+}
... ...
@@ -130,13 +130,17 @@ func (config *Config) DebugGCS() {
130 130
 	cmd := os.Getenv("OPENGCS_DEBUG_COMMAND")
131 131
 	if cmd == "" {
132 132
 		cmd = `sh -c "`
133
+		cmd += debugCommand("kill -10 `pidof gcs`") // SIGUSR1 for stackdump
133 134
 		cmd += debugCommand("ls -l /tmp")
134 135
 		cmd += debugCommand("cat /tmp/gcs.log")
136
+		cmd += debugCommand("cat /tmp/gcs/gcs-stacks*")
137
+		cmd += debugCommand("cat /tmp/gcs/paniclog*")
135 138
 		cmd += debugCommand("ls -l /tmp/gcs")
136 139
 		cmd += debugCommand("ls -l /tmp/gcs/*")
137 140
 		cmd += debugCommand("cat /tmp/gcs/*/config.json")
138 141
 		cmd += debugCommand("ls -lR /var/run/gcsrunc")
139
-		cmd += debugCommand("cat /var/run/gcsrunc/log.log")
142
+		cmd += debugCommand("cat /tmp/gcs/global-runc.log")
143
+		cmd += debugCommand("cat /tmp/gcs/*/runc.log")
140 144
 		cmd += debugCommand("ps -ef")
141 145
 		cmd += `"`
142 146
 	}
... ...
@@ -153,5 +157,5 @@ func (config *Config) DebugGCS() {
153 153
 	if proc != nil {
154 154
 		proc.WaitTimeout(time.Duration(int(time.Second) * 30))
155 155
 	}
156
-	logrus.Debugf("GCS Debugging:\n%s\n\nEnd GCS Debugging\n", strings.TrimSpace(out.String()))
156
+	logrus.Debugf("GCS Debugging:\n%s\n\nEnd GCS Debugging", strings.TrimSpace(out.String()))
157 157
 }
... ...
@@ -3,6 +3,8 @@
3 3
 package client
4 4
 
5 5
 import (
6
+	"bytes"
7
+	"encoding/hex"
6 8
 	"fmt"
7 9
 	"io"
8 10
 	"os"
... ...
@@ -40,7 +42,28 @@ func copyWithTimeout(dst io.Writer, src io.Reader, size int64, timeoutSeconds in
40 40
 	done := make(chan resultType, 1)
41 41
 	go func() {
42 42
 		result := resultType{}
43
-		result.bytes, result.err = io.Copy(dst, src)
43
+		if logrus.GetLevel() < logrus.DebugLevel || logDataFromUVM == 0 {
44
+			result.bytes, result.err = io.Copy(dst, src)
45
+		} else {
46
+			// In advanced debug mode where we log (hexdump format) what is copied
47
+			// up to the number of bytes defined by environment variable
48
+			// OPENGCS_LOG_DATA_FROM_UVM
49
+			var buf bytes.Buffer
50
+			tee := io.TeeReader(src, &buf)
51
+			result.bytes, result.err = io.Copy(dst, tee)
52
+			if result.err == nil {
53
+				size := result.bytes
54
+				if size > logDataFromUVM {
55
+					size = logDataFromUVM
56
+				}
57
+				if size > 0 {
58
+					bytes := make([]byte, size)
59
+					if _, err := buf.Read(bytes); err == nil {
60
+						logrus.Debugf(fmt.Sprintf("opengcs: copyWithTimeout\n%s", hex.Dump(bytes)))
61
+					}
62
+				}
63
+			}
64
+		}
44 65
 		done <- result
45 66
 	}()
46 67
 
... ...
@@ -43,6 +43,8 @@ func ExportedToError(ee *ExportedError) error {
43 43
 		return os.ErrExist
44 44
 	} else if ee.Error() == os.ErrPermission.Error() {
45 45
 		return os.ErrPermission
46
+	} else if ee.Error() == io.EOF.Error() {
47
+		return io.EOF
46 48
 	}
47 49
 	return ee
48 50
 }