Merge pull request #65456 from wenlxie/upstream.master.csivolumemode

Automatic merge from submit-queue (batch tested with PRs 65456, 65549). 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>.

add volume mode field to constructed volume spec for CSI plugin

Add volume mode filed to constructed Volume Spec for CSI plugin

```release-note
Add volume mode filed to constructed volume spec for CSI plugin
```
pull/8/head
Kubernetes Submit Queue 2018-07-09 06:24:03 -07:00 committed by GitHub
commit 9cb2ee0992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -248,6 +248,7 @@ func (p *csiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.S
glog.V(4).Info(log("plugin.ConstructVolumeSpec extracted [%#v]", volData))
fsMode := api.PersistentVolumeFilesystem
pv := &api.PersistentVolume{
ObjectMeta: meta.ObjectMeta{
Name: volData[volDataKey.specVolID],
@ -259,6 +260,7 @@ func (p *csiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volume.S
VolumeHandle: volData[volDataKey.volHandle],
},
},
VolumeMode: &fsMode,
},
}

View File

@ -186,6 +186,14 @@ func TestPluginConstructVolumeSpec(t *testing.T) {
t.Errorf("expected volID %s, got volID %s", tc.data[volDataKey.volHandle], volHandle)
}
if spec.PersistentVolume.Spec.VolumeMode == nil {
t.Fatalf("Volume mode has not been set.")
}
if *spec.PersistentVolume.Spec.VolumeMode != api.PersistentVolumeFilesystem {
t.Errorf("Unexpected volume mode %q", *spec.PersistentVolume.Spec.VolumeMode)
}
if spec.Name() != tc.specVolID {
t.Errorf("Unexpected spec name %s", spec.Name())
}
@ -463,6 +471,14 @@ func TestPluginConstructBlockVolumeSpec(t *testing.T) {
continue
}
if spec.PersistentVolume.Spec.VolumeMode == nil {
t.Fatalf("Volume mode has not been set.")
}
if *spec.PersistentVolume.Spec.VolumeMode != api.PersistentVolumeBlock {
t.Errorf("Unexpected volume mode %q", *spec.PersistentVolume.Spec.VolumeMode)
}
volHandle := spec.PersistentVolume.Spec.CSI.VolumeHandle
if volHandle != tc.data[volDataKey.volHandle] {
t.Errorf("expected volID %s, got volID %s", tc.data[volDataKey.volHandle], volHandle)