Skip to content

Commit c8d8152

Browse files
Add controller service capabilities
Signed-off-by: Mayank Shah <[email protected]>
1 parent e770516 commit c8d8152

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

pkg/nfs/controllerserver.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ func (cs *ControllerServer) internalMount(ctx context.Context, vol *nfsVolume) e
220220
_, err := cs.Driver.ns.NodePublishVolume(ctx, &csi.NodePublishVolumeRequest{
221221
TargetPath: targetPath,
222222
VolumeContext: map[string]string{
223-
"server": vol.server,
224-
"share": sharePath,
223+
paramServer: vol.server,
224+
attrShare: sharePath,
225225
},
226226
VolumeCapability: &stdVolCap,
227227
VolumeId: vol.id,
@@ -281,6 +281,10 @@ func (cs *ControllerServer) newNFSVolume(name string, params map[string]string)
281281

282282
// Get working directory for CreateVolume and DeleteVolume
283283
func (cs *ControllerServer) getInternalMountPath(vol *nfsVolume) string {
284+
// use default if empty
285+
if cs.workingMountDir == "" {
286+
cs.workingMountDir = "/mnt"
287+
}
284288
return filepath.Join(cs.workingMountDir, vol.subDir)
285289
}
286290

@@ -312,21 +316,6 @@ func (cs *ControllerServer) nfsVolToCSI(vol *nfsVolume, reqBytes int64) *csi.Vol
312316
}
313317
}
314318

315-
// Given a CSI volume id, return a nfsVolume
316-
func (cs *ControllerServer) getNfsVolFromId(id string) (*nfsVolume, error) {
317-
tokens := strings.Split(id, "/")
318-
if len(tokens) != totalIDElements {
319-
return nil, fmt.Errorf("volume id %q unexpected format: got %v tokens", id, len(tokens))
320-
}
321-
322-
return &nfsVolume{
323-
id: id,
324-
server: tokens[idServer],
325-
baseDir: tokens[idBaseDir],
326-
subDir: tokens[idSubDir],
327-
}, nil
328-
}
329-
330319
// Given a nfsVolume, return a CSI volume id
331320
func (cs *ControllerServer) getVolumeIdFromNfsVol(vol *nfsVolume) string {
332321
idElements := make([]string, totalIDElements)

pkg/nfs/nfs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ func NewNFSdriver(nodeID, endpoint string, perm *uint32) *nfsDriver {
6969
// NFS plugin does not support ControllerServiceCapability now.
7070
// If support is added, it should set to appropriate
7171
// ControllerServiceCapability RPC types.
72-
n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{csi.ControllerServiceCapability_RPC_UNKNOWN})
72+
n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
73+
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
74+
})
7375
return n
7476
}
7577

0 commit comments

Comments
 (0)