fix localvolume volume mode not found issue

This commit is contained in:
wenlxie 2018-06-21 20:01:58 +08:00
parent 1a75395da8
commit 23722fbdfa
2 changed files with 10 additions and 0 deletions

View File

@ -169,6 +169,7 @@ func (plugin *localVolumePlugin) NewBlockVolumeUnmapper(volName string,
// TODO: check if no path and no topology constraints are ok
func (plugin *localVolumePlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.Spec, error) {
fs := v1.PersistentVolumeFilesystem
localVolume := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: volumeName,
@ -179,6 +180,7 @@ func (plugin *localVolumePlugin) ConstructVolumeSpec(volumeName, mountPath strin
Path: "",
},
},
VolumeMode: &fs,
},
}
return volume.NewSpecFromPersistentVolume(localVolume, false), nil

View File

@ -336,6 +336,14 @@ func TestConstructVolumeSpec(t *testing.T) {
t.Fatalf("PersistentVolume object nil")
}
if spec.PersistentVolume.Spec.VolumeMode == nil {
t.Fatalf("Volume mode has not been set.")
}
if *spec.PersistentVolume.Spec.VolumeMode != v1.PersistentVolumeFilesystem {
t.Errorf("Unexpected volume mode %q", *spec.PersistentVolume.Spec.VolumeMode)
}
ls := pv.Spec.PersistentVolumeSource.Local
if ls == nil {
t.Fatalf("LocalVolumeSource object nil")