diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index f861925cc74..e74469d9bb8 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -1530,7 +1530,9 @@ type VolumeMount struct { // Optional: Defaults to false (read-write). // +optional ReadOnly bool - // Required. Must not contain ':'. + // Required. If the path is not an absolute path (e.g. some/path) it + // will be prepended with the appropriate root prefix for the operating + // system. On Linux this is '/', on Windows this is 'C:\'. MountPath string // Path within the volume from which the container's volume should be mounted. // Defaults to "" (volume's root). diff --git a/pkg/apis/core/validation/validation.go b/pkg/apis/core/validation/validation.go index 8fe283ddfeb..1dd944f10e7 100644 --- a/pkg/apis/core/validation/validation.go +++ b/pkg/apis/core/validation/validation.go @@ -1965,13 +1965,6 @@ func ValidateVolumeMounts(mounts []core.VolumeMount, volumes sets.String, contai if mountpoints.Has(mnt.MountPath) { allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be unique")) } - if !path.IsAbs(mnt.MountPath) { - // also allow windows absolute path - p := mnt.MountPath - if len(p) < 2 || ((p[0] < 'A' || p[0] > 'Z') && (p[0] < 'a' || p[0] > 'z')) || p[1] != ':' { - allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be an absolute path")) - } - } mountpoints.Insert(mnt.MountPath) if len(mnt.SubPath) > 0 { allErrs = append(allErrs, validateLocalDescendingPath(mnt.SubPath, fldPath.Child("subPath"))...) diff --git a/pkg/apis/core/validation/validation_test.go b/pkg/apis/core/validation/validation_test.go index 3a6121715ce..43cdd8a3ead 100644 --- a/pkg/apis/core/validation/validation_test.go +++ b/pkg/apis/core/validation/validation_test.go @@ -3849,10 +3849,8 @@ func TestValidateVolumeMounts(t *testing.T) { "empty name": {{Name: "", MountPath: "/foo"}}, "name not found": {{Name: "", MountPath: "/foo"}}, "empty mountpath": {{Name: "abc", MountPath: ""}}, - "relative mountpath": {{Name: "abc", MountPath: "bar"}}, "mountpath collision": {{Name: "foo", MountPath: "/path/a"}, {Name: "bar", MountPath: "/path/a"}}, "absolute subpath": {{Name: "abc", MountPath: "/bar", SubPath: "/baz"}}, - "windows absolute subpath": {{Name: "abc", MountPath: "D", SubPath: ""}}, "subpath in ..": {{Name: "abc", MountPath: "/bar", SubPath: "../baz"}}, "subpath contains ..": {{Name: "abc", MountPath: "/bar", SubPath: "baz/../bat"}}, "subpath ends in ..": {{Name: "abc", MountPath: "/bar", SubPath: "./.."}},