Merge pull request #51240 from andyzhangx/windows-abs-path

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

allow windows mount path

**What this PR does / why we need it**:
Currently mount path onlly allow Linux absolute path,  allow windows mount path in this PR.
This code snippet in kubelet will run in both Linux and Windows, so use IsAbs func to tell whether it's a absolute path is not sufficient as for k8s windows cluster, the master is Linux and agent is Windows node.

**Special notes for your reviewer**:
The example pod with mount path is like below:
```
---
kind: Pod
apiVersion: v1
metadata:
  name: pod-uses-shared-hdd-5g
  labels:
    name: storage
spec:
  containers:
  - image: microsoft/iis
    name: az-c-01
    volumeMounts:
    - name: blobdisk01
      mountPath: 'F:'
  nodeSelector:
    beta.kubernetes.io/os: windows
  volumes:
  - name: blobdisk01
    persistentVolumeClaim:
      claimName: pv-dd-shared-hdd-5
```


**Release note**:

```release-note
```
pull/6/head
Kubernetes Submit Queue 2017-10-26 18:39:49 -07:00 committed by GitHub
commit 87cefa0850
1 changed files with 5 additions and 1 deletions

View File

@ -1949,7 +1949,11 @@ func ValidateVolumeMounts(mounts []api.VolumeMount, volumes sets.String, contain
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be unique")) allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be unique"))
} }
if !path.IsAbs(mnt.MountPath) { if !path.IsAbs(mnt.MountPath) {
allErrs = append(allErrs, field.Invalid(idxPath.Child("mountPath"), mnt.MountPath, "must be an absolute path")) // 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) mountpoints.Insert(mnt.MountPath)
if len(mnt.SubPath) > 0 { if len(mnt.SubPath) > 0 {