Don't skip mounts if we can't find the volume
This commit is contained in:
parent
de2aec31d9
commit
266120c189
@ -127,8 +127,8 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
|
|||||||
mountEtcHostsFile = mountEtcHostsFile && (mount.MountPath != etcHostsPath)
|
mountEtcHostsFile = mountEtcHostsFile && (mount.MountPath != etcHostsPath)
|
||||||
vol, ok := podVolumes[mount.Name]
|
vol, ok := podVolumes[mount.Name]
|
||||||
if !ok || vol.Mounter == nil {
|
if !ok || vol.Mounter == nil {
|
||||||
glog.Warningf("Mount cannot be satisfied for container %q, because the volume is missing or the volume mounter is nil: %q", container.Name, mount)
|
glog.Errorf("Mount cannot be satisfied for container %q, because the volume is missing or the volume mounter is nil: %+v", container.Name, mount)
|
||||||
continue
|
return nil, fmt.Errorf("cannot find volume %q to mount into container %q", mount.Name, container.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
relabelVolume := false
|
relabelVolume := false
|
||||||
|
@ -223,6 +223,36 @@ func TestMakeMounts(t *testing.T) {
|
|||||||
expectErr: true,
|
expectErr: true,
|
||||||
expectedErrMsg: "unable to provision SubPath `no/backsteps/../allowed`: must not contain '..'",
|
expectedErrMsg: "unable to provision SubPath `no/backsteps/../allowed`: must not contain '..'",
|
||||||
},
|
},
|
||||||
|
"volume doesn't exist": {
|
||||||
|
podVolumes: kubecontainer.VolumeMap{},
|
||||||
|
container: v1.Container{
|
||||||
|
VolumeMounts: []v1.VolumeMount{
|
||||||
|
{
|
||||||
|
MountPath: "/mnt/path3",
|
||||||
|
Name: "disk",
|
||||||
|
ReadOnly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectErr: true,
|
||||||
|
expectedErrMsg: "cannot find volume \"disk\" to mount into container \"\"",
|
||||||
|
},
|
||||||
|
"volume mounter is nil": {
|
||||||
|
podVolumes: kubecontainer.VolumeMap{
|
||||||
|
"disk": kubecontainer.VolumeInfo{},
|
||||||
|
},
|
||||||
|
container: v1.Container{
|
||||||
|
VolumeMounts: []v1.VolumeMount{
|
||||||
|
{
|
||||||
|
MountPath: "/mnt/path3",
|
||||||
|
Name: "disk",
|
||||||
|
ReadOnly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectErr: true,
|
||||||
|
expectedErrMsg: "cannot find volume \"disk\" to mount into container \"\"",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, tc := range testCases {
|
for name, tc := range testCases {
|
||||||
|
Loading…
Reference in New Issue
Block a user