mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
LCOW: Log stderr on failures
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
d0970ab9a4
commit
63f9c7784b
3 changed files with 21 additions and 10 deletions
|
@ -2,6 +2,7 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/builder/remotecontext"
|
"github.com/docker/docker/builder/remotecontext"
|
||||||
|
@ -97,7 +98,9 @@ func initDispatchTestCases() []dispatchTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDispatch(t *testing.T) {
|
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()
|
testCases := initDispatchTestCases()
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
|
|
@ -47,6 +47,9 @@ func TestDockerfileOutsideTheBuildContext(t *testing.T) {
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
expectedError := "Forbidden path outside the build context: ../../Dockerfile ()"
|
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)
|
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) {
|
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)
|
tarStream, err := archive.Tar(contextDir, archive.Uncompressed)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
@ -80,7 +85,7 @@ func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath,
|
||||||
Source: tarStream,
|
Source: tarStream,
|
||||||
}
|
}
|
||||||
_, _, err = remotecontext.Detect(config)
|
_, _, err = remotecontext.Detect(config)
|
||||||
assert.Check(t, is.Error(err, expectedError))
|
assert.Check(t, is.ErrorContains(err, expectedError))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCopyRunConfig(t *testing.T) {
|
func TestCopyRunConfig(t *testing.T) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ package lcow // import "github.com/docker/docker/daemon/graphdriver/lcow"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -13,6 +12,7 @@ import (
|
||||||
|
|
||||||
"github.com/Microsoft/hcsshim"
|
"github.com/Microsoft/hcsshim"
|
||||||
"github.com/Microsoft/opengcs/client"
|
"github.com/Microsoft/opengcs/client"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"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)
|
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 {
|
errOut := &bytes.Buffer{}
|
||||||
return err
|
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
|
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]))
|
upper := fmt.Sprintf("%s/upper", svm.getShortContainerPath(&mvds[0]))
|
||||||
work := fmt.Sprintf("%s/work", 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 {
|
errOut := &bytes.Buffer{}
|
||||||
return err
|
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",
|
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)
|
logrus.Debugf("createUnionMount: Executing mount=%s", cmd)
|
||||||
if err = svm.runProcess(cmd, nil, nil, nil); err != nil {
|
errOut = &bytes.Buffer{}
|
||||||
return err
|
if err = svm.runProcess(cmd, nil, nil, errOut); err != nil {
|
||||||
|
return errors.Wrapf(err, "%s failed (%s)", cmd, errOut.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
svm.unionMounts[mountName] = 1
|
svm.unionMounts[mountName] = 1
|
||||||
|
|
Loading…
Reference in a new issue