Browse Source

Windows [TP4] Trap Exec Hyper-V Cont error

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard 9 years ago
parent
commit
2e56e78caf
2 changed files with 9 additions and 2 deletions
  1. 8 1
      daemon/execdriver/windows/exec.go
  2. 1 1
      daemon/execdriver/windows/run.go

+ 8 - 1
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
 	}

+ 1 - 1
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