From 790b67c89f26b9bc77957caf41115bd09c3bda53 Mon Sep 17 00:00:00 2001 From: Michelle Au Date: Mon, 12 Aug 2019 17:45:56 -0700 Subject: [PATCH] Add more access modes to volume capabilities --- pkg/nfs/nfs.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/nfs/nfs.go b/pkg/nfs/nfs.go index c5378337c..449b0d9b6 100644 --- a/pkg/nfs/nfs.go +++ b/pkg/nfs/nfs.go @@ -30,7 +30,7 @@ type nfsDriver struct { //ids *identityServer ns *nodeServer - cap []*csi.VolumeCapability_AccessMode + cap map[csi.VolumeCapability_AccessMode_Mode]bool cscap []*csi.ControllerServiceCapability } @@ -50,9 +50,18 @@ func NewNFSdriver(nodeID, endpoint string) *nfsDriver { version: version, nodeID: nodeID, endpoint: endpoint, + cap: map[csi.VolumeCapability_AccessMode_Mode]bool{}, } - n.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER}) + vcam := []csi.VolumeCapability_AccessMode_Mode{ + csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY, + csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY, + csi.VolumeCapability_AccessMode_MULTI_NODE_SINGLE_WRITER, + csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER, + } + n.AddVolumeCapabilityAccessModes(vcam) + // NFS plugin does not support ControllerServiceCapability now. // If support is added, it should set to appropriate // ControllerServiceCapability RPC types. @@ -83,8 +92,8 @@ func (n *nfsDriver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_Acc for _, c := range vc { glog.Infof("Enabling volume access mode: %v", c.String()) vca = append(vca, &csi.VolumeCapability_AccessMode{Mode: c}) + n.cap[c] = true } - n.cap = vca return vca }