LCOW: Capture stderr on external process. Log actual error rather than throwaway
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
f586fe5637
commit
dffc966165
2 changed files with 20 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containerd/continuity/driver"
|
"github.com/containerd/continuity/driver"
|
||||||
|
@ -173,6 +174,9 @@ func StatAt(remote builder.Source, path string) (os.FileInfo, error) {
|
||||||
func FullPath(remote builder.Source, path string) (string, error) {
|
func FullPath(remote builder.Source, path string) (string, error) {
|
||||||
fullPath, err := remote.Root().ResolveScopedPath(path, true)
|
fullPath, err := remote.Root().ResolveScopedPath(path, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
return "", fmt.Errorf("failed to resolve scoped path %s (%s): %s. Possible cause is a forbidden path outside the build context", path, fullPath, err)
|
||||||
|
}
|
||||||
return "", fmt.Errorf("Forbidden path outside the build context: %s (%s)", path, fullPath) // backwards compat with old error
|
return "", fmt.Errorf("Forbidden path outside the build context: %s (%s)", path, fullPath) // backwards compat with old error
|
||||||
}
|
}
|
||||||
return fullPath, nil
|
return fullPath, nil
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
package lcow // import "github.com/docker/docker/daemon/graphdriver/lcow"
|
package lcow // import "github.com/docker/docker/daemon/graphdriver/lcow"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -385,7 +386,15 @@ func (svm *serviceVM) deleteUnionMount(mountName string, disks ...hcsshim.Mapped
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svm *serviceVM) runProcess(command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
|
func (svm *serviceVM) runProcess(command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
|
||||||
process, err := svm.config.RunProcess(command, stdin, stdout, stderr)
|
var process hcsshim.Process
|
||||||
|
var err error
|
||||||
|
errOut := &bytes.Buffer{}
|
||||||
|
|
||||||
|
if stderr != nil {
|
||||||
|
process, err = svm.config.RunProcess(command, stdin, stdout, stderr)
|
||||||
|
} else {
|
||||||
|
process, err = svm.config.RunProcess(command, stdin, stdout, errOut)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -398,7 +407,12 @@ func (svm *serviceVM) runProcess(command string, stdin io.Reader, stdout io.Writ
|
||||||
}
|
}
|
||||||
|
|
||||||
if exitCode != 0 {
|
if exitCode != 0 {
|
||||||
return fmt.Errorf("svm.runProcess: command %s failed with exit code %d", command, exitCode)
|
// If the caller isn't explicitly capturing stderr output, then capture it here instead.
|
||||||
|
e := fmt.Sprintf("svm.runProcess: command %s failed with exit code %d", command, exitCode)
|
||||||
|
if stderr == nil {
|
||||||
|
e = fmt.Sprintf("%s. (%s)", e, errOut.String())
|
||||||
|
}
|
||||||
|
return fmt.Errorf(e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue