Browse code

Windows [TP4] Trap Exec Hyper-V Cont error

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

John Howard authored on 2015/10/24 00:42:24
Showing 2 changed files
... ...
@@ -51,8 +51,15 @@ func (d *Driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessCo
51 51
 	logrus.Debugln("commandLine: ", createProcessParms.CommandLine)
52 52
 
53 53
 	// Start the command running in the container.
54
-	pid, stdin, stdout, stderr, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !processConfig.Tty, createProcessParms)
54
+	pid, stdin, stdout, stderr, rc, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !processConfig.Tty, createProcessParms)
55 55
 	if err != nil {
56
+		// TODO Windows: TP4 Workaround. In Hyper-V containers, there is a limitation
57
+		// of one exec per container. This should be fixed post TP4. CreateProcessInComputeSystem
58
+		// will return a specific error which we handle here to give a good error message
59
+		// back to the user instead of an inactionable "An invalid argument was supplied"
60
+		if rc == hcsshim.Win32InvalidArgument {
61
+			return -1, fmt.Errorf("The limit of docker execs per Hyper-V container has been exceeded")
62
+		}
56 63
 		logrus.Errorf("CreateProcessInComputeSystem() failed %s", err)
57 64
 		return -1, err
58 65
 	}
... ...
@@ -263,7 +263,7 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
263 263
 	logrus.Debugf("CommandLine: %s", createProcessParms.CommandLine)
264 264
 
265 265
 	// Start the command running in the container.
266
-	pid, stdin, stdout, stderr, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !c.ProcessConfig.Tty, createProcessParms)
266
+	pid, stdin, stdout, stderr, _, err := hcsshim.CreateProcessInComputeSystem(c.ID, pipes.Stdin != nil, true, !c.ProcessConfig.Tty, createProcessParms)
267 267
 	if err != nil {
268 268
 		logrus.Errorf("CreateProcessInComputeSystem() failed %s", err)
269 269
 		return execdriver.ExitStatus{ExitCode: -1}, err