Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -439,6 +439,11 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly |
| 439 | 439 |
if err != nil {
|
| 440 | 440 |
return -1, err |
| 441 | 441 |
} |
| 442 |
+ |
|
| 443 |
+ defer func() {
|
|
| 444 |
+ container.debugGCS() |
|
| 445 |
+ }() |
|
| 446 |
+ |
|
| 442 | 447 |
// Note we always tell HCS to |
| 443 | 448 |
// create stdout as it's required regardless of '-i' or '-t' options, so that |
| 444 | 449 |
// docker can always grab the output through logs. We also tell HCS to always |
| ... | ... |
@@ -50,6 +50,7 @@ func (ctr *container) start(attachStdio StdioCallback) error {
|
| 50 | 50 |
logrus.Debugln("libcontainerd: starting container ", ctr.containerID)
|
| 51 | 51 |
if err = ctr.hcsContainer.Start(); err != nil {
|
| 52 | 52 |
logrus.Errorf("libcontainerd: failed to start container: %s", err)
|
| 53 |
+ ctr.debugGCS() // Before terminating! |
|
| 53 | 54 |
if err := ctr.terminate(); err != nil {
|
| 54 | 55 |
logrus.Errorf("libcontainerd: failed to cleanup after a failed Start. %s", err)
|
| 55 | 56 |
} else {
|
| ... | ... |
@@ -58,6 +59,10 @@ func (ctr *container) start(attachStdio StdioCallback) error {
|
| 58 | 58 |
return err |
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 |
+ defer func() {
|
|
| 62 |
+ ctr.debugGCS() |
|
| 63 |
+ }() |
|
| 64 |
+ |
|
| 61 | 65 |
// Note we always tell HCS to |
| 62 | 66 |
// create stdout as it's required regardless of '-i' or '-t' options, so that |
| 63 | 67 |
// docker can always grab the output through logs. We also tell HCS to always |
| ... | ... |
@@ -1,6 +1,10 @@ |
| 1 | 1 |
package libcontainerd |
| 2 | 2 |
|
| 3 |
-import "strings" |
|
| 3 |
+import ( |
|
| 4 |
+ "strings" |
|
| 5 |
+ |
|
| 6 |
+ opengcs "github.com/Microsoft/opengcs/client" |
|
| 7 |
+) |
|
| 4 | 8 |
|
| 5 | 9 |
// setupEnvironmentVariables converts a string array of environment variables |
| 6 | 10 |
// 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 {
|
| 19 | 19 |
func (s *LCOWOption) Apply(interface{}) error {
|
| 20 | 20 |
return nil |
| 21 | 21 |
} |
| 22 |
+ |
|
| 23 |
+// DebugGCS is a dirty hack for debugging for Linux Utility VMs. It simply |
|
| 24 |
+// runs a bunch of commands inside the UVM, but seriously aides in advanced debugging. |
|
| 25 |
+func (c *container) debugGCS() {
|
|
| 26 |
+ if c == nil || c.isWindows || c.hcsContainer == nil {
|
|
| 27 |
+ return |
|
| 28 |
+ } |
|
| 29 |
+ cfg := opengcs.Config{
|
|
| 30 |
+ Uvm: c.hcsContainer, |
|
| 31 |
+ UvmTimeoutSeconds: 600, |
|
| 32 |
+ } |
|
| 33 |
+ cfg.DebugGCS() |
|
| 34 |
+} |