Merge pull request #17383 from Microsoft/10662-volumeerrors

Fix volume error messages
This commit is contained in:
Brian Goff 2015-11-05 21:58:03 -05:00
commit f1834153de
3 changed files with 13 additions and 13 deletions

View File

@ -367,11 +367,11 @@ var (
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
// ErrorCodeVolumeInvalidMode is generated when we the mode of a volume/bind // ErrorCodeVolumeInvalidMode is generated when the mode of a volume/bind
// mount is invalid. // mount is invalid.
ErrorCodeVolumeInvalidMode = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeInvalidMode = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEINVALIDMODE", Value: "VOLUMEINVALIDMODE",
Message: "invalid mode: %s", Message: "invalid mode: %q",
Description: "An invalid 'mode' was specified", Description: "An invalid 'mode' was specified",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
@ -380,7 +380,7 @@ var (
// volume specification isn't valid. // volume specification isn't valid.
ErrorCodeVolumeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEINVALID", Value: "VOLUMEINVALID",
Message: "Invalid volume specification: %s", Message: "Invalid volume specification: '%s'",
Description: "An invalid 'volume' was specified in the mount request", Description: "An invalid 'volume' was specified in the mount request",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
@ -388,7 +388,7 @@ var (
// ErrorCodeVolumeAbs is generated when path to a volume isn't absolute. // ErrorCodeVolumeAbs is generated when path to a volume isn't absolute.
ErrorCodeVolumeAbs = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeAbs = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEABS", Value: "VOLUMEABS",
Message: "Invalid volume destination path: %s mount path must be absolute.", Message: "Invalid volume destination path: '%s' mount path must be absolute.",
Description: "An invalid 'destination' path was specified in the mount request, it must be an absolute path", Description: "An invalid 'destination' path was specified in the mount request, it must be an absolute path",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
@ -396,7 +396,7 @@ var (
// ErrorCodeVolumeName is generated when the name of named volume isn't valid. // ErrorCodeVolumeName is generated when the name of named volume isn't valid.
ErrorCodeVolumeName = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeName = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUME_NAME_INVALID", Value: "VOLUME_NAME_INVALID",
Message: "%s includes invalid characters for a local volume name, only %s are allowed", Message: "%q includes invalid characters for a local volume name, only %q are allowed",
Description: "The name of volume is invalid", Description: "The name of volume is invalid",
HTTPStatusCode: http.StatusBadRequest, HTTPStatusCode: http.StatusBadRequest,
}) })
@ -425,7 +425,7 @@ var (
// ErrorCodeVolumeSourceNotFound is generated the source directory could not be found (Windows specific) // ErrorCodeVolumeSourceNotFound is generated the source directory could not be found (Windows specific)
ErrorCodeVolumeSourceNotFound = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeSourceNotFound = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMESOURCENOTFOUND", Value: "VOLUMESOURCENOTFOUND",
Message: "Source directory '%s' could not be found: %v", Message: "Source directory '%s' could not be found: %s",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
@ -439,7 +439,7 @@ var (
// ErrorCodeVolumeFromBlank is generated when path to a volume is blank. // ErrorCodeVolumeFromBlank is generated when path to a volume is blank.
ErrorCodeVolumeFromBlank = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeFromBlank = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEFROMBLANK", Value: "VOLUMEFROMBLANK",
Message: "malformed volumes-from specification: %s", Message: "malformed volumes-from specification: %q",
Description: "An invalid 'destination' path was specified in the mount request, it must not be blank", Description: "An invalid 'destination' path was specified in the mount request, it must not be blank",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
@ -448,7 +448,7 @@ var (
// to the same path. // to the same path.
ErrorCodeVolumeDup = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeDup = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEDUP", Value: "VOLUMEDUP",
Message: "Duplicate bind mount %s", Message: "Duplicate bind mount '%s'",
Description: "An attempt was made to mount a volume but the specified destination location is already used in a previous mount", Description: "An attempt was made to mount a volume but the specified destination location is already used in a previous mount",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })
@ -457,7 +457,7 @@ var (
// for a volume mount was found. (Windows specific) // for a volume mount was found. (Windows specific)
ErrorCodeVolumeNoSourceForMount = errcode.Register(errGroup, errcode.ErrorDescriptor{ ErrorCodeVolumeNoSourceForMount = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMENOSOURCEFORMOUNT", Value: "VOLUMENOSOURCEFORMOUNT",
Message: "No source for mount name %q driver %q destination %s", Message: "No source for mount name '%s' driver %q destination '%s'",
HTTPStatusCode: http.StatusInternalServerError, HTTPStatusCode: http.StatusInternalServerError,
}) })

View File

@ -344,8 +344,8 @@ func (s *DockerSuite) TestRunVolumesFromInReadWriteMode(c *check.C) {
dockerCmd(c, "run", "--name", "parent", "-v", volumeDir, "busybox", "true") dockerCmd(c, "run", "--name", "parent", "-v", volumeDir, "busybox", "true")
dockerCmd(c, "run", "--volumes-from", "parent:rw", "busybox", "touch", fileInVol) dockerCmd(c, "run", "--volumes-from", "parent:rw", "busybox", "touch", fileInVol)
if out, _, err := dockerCmdWithError("run", "--volumes-from", "parent:bar", "busybox", "touch", fileInVol); err == nil || !strings.Contains(out, "invalid mode: bar") { if out, _, err := dockerCmdWithError("run", "--volumes-from", "parent:bar", "busybox", "touch", fileInVol); err == nil || !strings.Contains(out, `invalid mode: "bar"`) {
c.Fatalf("running --volumes-from parent:bar should have failed with invalid mount mode: %q", out) c.Fatalf("running --volumes-from parent:bar should have failed with invalid mode: %q", out)
} }
dockerCmd(c, "run", "--volumes-from", "parent", "busybox", "touch", fileInVol) dockerCmd(c, "run", "--volumes-from", "parent", "busybox", "touch", fileInVol)

View File

@ -111,8 +111,8 @@ func TestParseMountSpec(t *testing.T) {
"/path:ro": "Invalid volume specification", "/path:ro": "Invalid volume specification",
"/rw:rw": "Invalid volume specification", "/rw:rw": "Invalid volume specification",
"path:ro": "Invalid volume specification", "path:ro": "Invalid volume specification",
"/path:/path:sw": "invalid mode: sw", "/path:/path:sw": `invalid mode: "sw"`,
"/path:/path:rwz": "invalid mode: rwz", "/path:/path:rwz": `invalid mode: "rwz"`,
} }
} }