LCOW: Add GCS debugging

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2017-09-08 13:35:01 -07:00
parent a15cdd707a
commit 5a0e2beac3
3 changed files with 28 additions and 1 deletions

View file

@ -439,6 +439,11 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly
if err != nil {
return -1, err
}
defer func() {
container.debugGCS()
}()
// Note we always tell HCS to
// create stdout as it's required regardless of '-i' or '-t' options, so that
// docker can always grab the output through logs. We also tell HCS to always

View file

@ -50,6 +50,7 @@ func (ctr *container) start(attachStdio StdioCallback) error {
logrus.Debugln("libcontainerd: starting container ", ctr.containerID)
if err = ctr.hcsContainer.Start(); err != nil {
logrus.Errorf("libcontainerd: failed to start container: %s", err)
ctr.debugGCS() // Before terminating!
if err := ctr.terminate(); err != nil {
logrus.Errorf("libcontainerd: failed to cleanup after a failed Start. %s", err)
} else {
@ -58,6 +59,10 @@ func (ctr *container) start(attachStdio StdioCallback) error {
return err
}
defer func() {
ctr.debugGCS()
}()
// Note we always tell HCS to
// create stdout as it's required regardless of '-i' or '-t' options, so that
// docker can always grab the output through logs. We also tell HCS to always

View file

@ -1,6 +1,10 @@
package libcontainerd
import "strings"
import (
"strings"
opengcs "github.com/Microsoft/opengcs/client"
)
// setupEnvironmentVariables converts a string array of environment variables
// into a map as required by the HCS. Source array is in format [v1=k1] [v2=k2] etc.
@ -19,3 +23,16 @@ func setupEnvironmentVariables(a []string) map[string]string {
func (s *LCOWOption) Apply(interface{}) error {
return nil
}
// DebugGCS is a dirty hack for debugging for Linux Utility VMs. It simply
// runs a bunch of commands inside the UVM, but seriously aides in advanced debugging.
func (c *container) debugGCS() {
if c == nil || c.isWindows || c.hcsContainer == nil {
return
}
cfg := opengcs.Config{
Uvm: c.hcsContainer,
UvmTimeoutSeconds: 600,
}
cfg.DebugGCS()
}