From 2cf544120b6a52256616e35b798ff8ef9d51893b Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 18 Jan 2018 17:52:40 -0800 Subject: [PATCH] Revendor Microsoft/opengcs @ v0.3.5 Signed-off-by: John Howard Upstream-commit: 042f53737cec84e2f1419e20fe37dd0eb1d5a9fa Component: engine --- components/engine/vendor.conf | 2 +- .../Microsoft/opengcs/client/init.go | 24 ++++++++++++++++++ .../Microsoft/opengcs/client/process.go | 8 ++++-- .../Microsoft/opengcs/client/utilities.go | 25 ++++++++++++++++++- .../service/gcsutils/remotefs/utils.go | 2 ++ 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 components/engine/vendor/github.com/Microsoft/opengcs/client/init.go diff --git a/components/engine/vendor.conf b/components/engine/vendor.conf index b417be6951..5e32743ccb 100644 --- a/components/engine/vendor.conf +++ b/components/engine/vendor.conf @@ -7,7 +7,7 @@ github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git github.com/gorilla/context v1.1 github.com/gorilla/mux v1.1 -github.com/Microsoft/opengcs v0.3.4 +github.com/Microsoft/opengcs v0.3.5 github.com/kr/pty 5cf931ef8f github.com/mattn/go-shellwords v1.0.3 github.com/sirupsen/logrus v1.0.3 diff --git a/components/engine/vendor/github.com/Microsoft/opengcs/client/init.go b/components/engine/vendor/github.com/Microsoft/opengcs/client/init.go new file mode 100644 index 0000000000..246ac185e9 --- /dev/null +++ b/components/engine/vendor/github.com/Microsoft/opengcs/client/init.go @@ -0,0 +1,24 @@ +// +build windows + +package client + +import ( + "os" + "strconv" +) + +var ( + logDataFromUVM int64 +) + +func init() { + bytes := os.Getenv("OPENGCS_LOG_DATA_FROM_UVM") + if len(bytes) == 0 { + return + } + u, err := strconv.ParseUint(bytes, 10, 32) + if err != nil { + return + } + logDataFromUVM = int64(u) +} diff --git a/components/engine/vendor/github.com/Microsoft/opengcs/client/process.go b/components/engine/vendor/github.com/Microsoft/opengcs/client/process.go index 958fdb5d0b..2b98f5331e 100644 --- a/components/engine/vendor/github.com/Microsoft/opengcs/client/process.go +++ b/components/engine/vendor/github.com/Microsoft/opengcs/client/process.go @@ -130,13 +130,17 @@ func (config *Config) DebugGCS() { cmd := os.Getenv("OPENGCS_DEBUG_COMMAND") if cmd == "" { cmd = `sh -c "` + cmd += debugCommand("kill -10 `pidof gcs`") // SIGUSR1 for stackdump cmd += debugCommand("ls -l /tmp") cmd += debugCommand("cat /tmp/gcs.log") + cmd += debugCommand("cat /tmp/gcs/gcs-stacks*") + cmd += debugCommand("cat /tmp/gcs/paniclog*") cmd += debugCommand("ls -l /tmp/gcs") cmd += debugCommand("ls -l /tmp/gcs/*") cmd += debugCommand("cat /tmp/gcs/*/config.json") cmd += debugCommand("ls -lR /var/run/gcsrunc") - cmd += debugCommand("cat /var/run/gcsrunc/log.log") + cmd += debugCommand("cat /tmp/gcs/global-runc.log") + cmd += debugCommand("cat /tmp/gcs/*/runc.log") cmd += debugCommand("ps -ef") cmd += `"` } @@ -153,5 +157,5 @@ func (config *Config) DebugGCS() { if proc != nil { proc.WaitTimeout(time.Duration(int(time.Second) * 30)) } - logrus.Debugf("GCS Debugging:\n%s\n\nEnd GCS Debugging\n", strings.TrimSpace(out.String())) + logrus.Debugf("GCS Debugging:\n%s\n\nEnd GCS Debugging", strings.TrimSpace(out.String())) } diff --git a/components/engine/vendor/github.com/Microsoft/opengcs/client/utilities.go b/components/engine/vendor/github.com/Microsoft/opengcs/client/utilities.go index cd779f15c4..8441d960f4 100644 --- a/components/engine/vendor/github.com/Microsoft/opengcs/client/utilities.go +++ b/components/engine/vendor/github.com/Microsoft/opengcs/client/utilities.go @@ -3,6 +3,8 @@ package client import ( + "bytes" + "encoding/hex" "fmt" "io" "os" @@ -40,7 +42,28 @@ func copyWithTimeout(dst io.Writer, src io.Reader, size int64, timeoutSeconds in done := make(chan resultType, 1) go func() { result := resultType{} - result.bytes, result.err = io.Copy(dst, src) + if logrus.GetLevel() < logrus.DebugLevel || logDataFromUVM == 0 { + result.bytes, result.err = io.Copy(dst, src) + } else { + // In advanced debug mode where we log (hexdump format) what is copied + // up to the number of bytes defined by environment variable + // OPENGCS_LOG_DATA_FROM_UVM + var buf bytes.Buffer + tee := io.TeeReader(src, &buf) + result.bytes, result.err = io.Copy(dst, tee) + if result.err == nil { + size := result.bytes + if size > logDataFromUVM { + size = logDataFromUVM + } + if size > 0 { + bytes := make([]byte, size) + if _, err := buf.Read(bytes); err == nil { + logrus.Debugf(fmt.Sprintf("opengcs: copyWithTimeout\n%s", hex.Dump(bytes))) + } + } + } + } done <- result }() diff --git a/components/engine/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go b/components/engine/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go index a12827c93f..727fd50e5a 100644 --- a/components/engine/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go +++ b/components/engine/vendor/github.com/Microsoft/opengcs/service/gcsutils/remotefs/utils.go @@ -43,6 +43,8 @@ func ExportedToError(ee *ExportedError) error { return os.ErrExist } else if ee.Error() == os.ErrPermission.Error() { return os.ErrPermission + } else if ee.Error() == io.EOF.Error() { + return io.EOF } return ee }