From 63f9c7784b7c6a726c8c668d68f9c8cb13e19ffb Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 8 Mar 2018 09:53:27 -0800 Subject: [PATCH] LCOW: Log stderr on failures Signed-off-by: John Howard --- builder/dockerfile/evaluator_test.go | 5 ++++- builder/dockerfile/internals_test.go | 9 +++++++-- daemon/graphdriver/lcow/lcow_svm.go | 17 ++++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/builder/dockerfile/evaluator_test.go b/builder/dockerfile/evaluator_test.go index fb79b238e8..28607ead0d 100644 --- a/builder/dockerfile/evaluator_test.go +++ b/builder/dockerfile/evaluator_test.go @@ -2,6 +2,7 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile" import ( "os" + "runtime" "testing" "github.com/docker/docker/builder/remotecontext" @@ -97,7 +98,9 @@ func initDispatchTestCases() []dispatchTestCase { } func TestDispatch(t *testing.T) { - skip.If(t, os.Getuid() != 0, "skipping test that requires root") + if runtime.GOOS != "windows" { + skip.If(t, os.Getuid() != 0, "skipping test that requires root") + } testCases := initDispatchTestCases() for _, testCase := range testCases { diff --git a/builder/dockerfile/internals_test.go b/builder/dockerfile/internals_test.go index 1c34fd3871..b1ef6c80d8 100644 --- a/builder/dockerfile/internals_test.go +++ b/builder/dockerfile/internals_test.go @@ -47,6 +47,9 @@ func TestDockerfileOutsideTheBuildContext(t *testing.T) { defer cleanup() expectedError := "Forbidden path outside the build context: ../../Dockerfile ()" + if runtime.GOOS == "windows" { + expectedError = "failed to resolve scoped path ../../Dockerfile ()" + } readAndCheckDockerfile(t, "DockerfileOutsideTheBuildContext", contextDir, "../../Dockerfile", expectedError) } @@ -61,7 +64,9 @@ func TestNonExistingDockerfile(t *testing.T) { } func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath, expectedError string) { - skip.If(t, os.Getuid() != 0, "skipping test that requires root") + if runtime.GOOS != "windows" { + skip.If(t, os.Getuid() != 0, "skipping test that requires root") + } tarStream, err := archive.Tar(contextDir, archive.Uncompressed) assert.NilError(t, err) @@ -80,7 +85,7 @@ func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath, Source: tarStream, } _, _, err = remotecontext.Detect(config) - assert.Check(t, is.Error(err, expectedError)) + assert.Check(t, is.ErrorContains(err, expectedError)) } func TestCopyRunConfig(t *testing.T) { diff --git a/daemon/graphdriver/lcow/lcow_svm.go b/daemon/graphdriver/lcow/lcow_svm.go index fdb0553dee..a70e1b2486 100644 --- a/daemon/graphdriver/lcow/lcow_svm.go +++ b/daemon/graphdriver/lcow/lcow_svm.go @@ -4,7 +4,6 @@ package lcow // import "github.com/docker/docker/daemon/graphdriver/lcow" import ( "bytes" - "errors" "fmt" "io" "strings" @@ -13,6 +12,7 @@ import ( "github.com/Microsoft/hcsshim" "github.com/Microsoft/opengcs/client" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -323,8 +323,9 @@ func (svm *serviceVM) createUnionMount(mountName string, mvds ...hcsshim.MappedV } logrus.Debugf("Doing the overlay mount with union directory=%s", mountName) - if err = svm.runProcess(fmt.Sprintf("mkdir -p %s", mountName), nil, nil, nil); err != nil { - return err + errOut := &bytes.Buffer{} + if err = svm.runProcess(fmt.Sprintf("mkdir -p %s", mountName), nil, nil, errOut); err != nil { + return errors.Wrapf(err, "mkdir -p %s failed (%s)", mountName, errOut.String()) } var cmd string @@ -340,8 +341,9 @@ func (svm *serviceVM) createUnionMount(mountName string, mvds ...hcsshim.MappedV upper := fmt.Sprintf("%s/upper", svm.getShortContainerPath(&mvds[0])) work := fmt.Sprintf("%s/work", svm.getShortContainerPath(&mvds[0])) - if err = svm.runProcess(fmt.Sprintf("mkdir -p %s %s", upper, work), nil, nil, nil); err != nil { - return err + errOut := &bytes.Buffer{} + if err = svm.runProcess(fmt.Sprintf("mkdir -p %s %s", upper, work), nil, nil, errOut); err != nil { + return errors.Wrapf(err, "mkdir -p %s failed (%s)", mountName, errOut.String()) } cmd = fmt.Sprintf("mount -t overlay overlay -olowerdir=%s,upperdir=%s,workdir=%s %s", @@ -352,8 +354,9 @@ func (svm *serviceVM) createUnionMount(mountName string, mvds ...hcsshim.MappedV } logrus.Debugf("createUnionMount: Executing mount=%s", cmd) - if err = svm.runProcess(cmd, nil, nil, nil); err != nil { - return err + errOut = &bytes.Buffer{} + if err = svm.runProcess(cmd, nil, nil, errOut); err != nil { + return errors.Wrapf(err, "%s failed (%s)", cmd, errOut.String()) } svm.unionMounts[mountName] = 1