From 2e56e78caf4e7cfe026ebb549e4419f1c4434817 Mon Sep 17 00:00:00 2001 From: John Howard Date: Fri, 23 Oct 2015 08:42:24 -0700 Subject: [PATCH] Windows [TP4] Trap Exec Hyper-V Cont error Signed-off-by: John Howard --- daemon/execdriver/windows/exec.go | 9 ++++++++- daemon/execdriver/windows/run.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/daemon/execdriver/windows/exec.go b/daemon/execdriver/windows/exec.go index 241997e2ff..85fda473a8 100644 --- a/daemon/execdriver/windows/exec.go +++ b/daemon/execdriver/windows/exec.go @@ -51,8 +51,15 @@ func (d *Driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessCo logrus.Debugln("commandLine: ", createProcessParms.CommandLine) // Start the command running in the container. - pid, stdin, stdout, stderr, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !processConfig.Tty, createProcessParms) + pid, stdin, stdout, stderr, rc, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !processConfig.Tty, createProcessParms) if err != nil { + // TODO Windows: TP4 Workaround. In Hyper-V containers, there is a limitation + // of one exec per container. This should be fixed post TP4. CreateProcessInComputeSystem + // will return a specific error which we handle here to give a good error message + // back to the user instead of an inactionable "An invalid argument was supplied" + if rc == hcsshim.Win32InvalidArgument { + return -1, fmt.Errorf("The limit of docker execs per Hyper-V container has been exceeded") + } logrus.Errorf("CreateProcessInComputeSystem() failed %s", err) return -1, err } diff --git a/daemon/execdriver/windows/run.go b/daemon/execdriver/windows/run.go index 98d8d1c921..7d03061855 100644 --- a/daemon/execdriver/windows/run.go +++ b/daemon/execdriver/windows/run.go @@ -263,7 +263,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd logrus.Debugf("CommandLine: %s", createProcessParms.CommandLine) // Start the command running in the container. - pid, stdin, stdout, stderr, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !c.ProcessConfig.Tty, createProcessParms) + pid, stdin, stdout, stderr, _, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !c.ProcessConfig.Tty, createProcessParms) if err != nil { logrus.Errorf("CreateProcessInComputeSystem() failed %s", err) return execdriver.ExitStatus{ExitCode: -1}, err