Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/driver-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ volumeAttributes.server | NFS Server address | domain name `nfs-server.default.s
volumeAttributes.share | NFS share path | `/` | Yes |
volumeAttributes.mountPermissions | mounted folder permissions. The default is `0`, if set as non-zero, driver will perform `chmod` after mount | | No |

### `VolumeSnapshotClass`

Name | Meaning | Available Value | Mandatory | Default value
--- | --- | --- | --- | ---
mountOptions | mount options separated by comma, e.g. `"nfsvers=4.1,sec=sys"` | | No | ""
server | NFS Server address | domain name `nfs-server.default.svc.cluster.local` <br>or IP address `127.0.0.1` | Yes |
share | NFS share path | `/` | Yes |

### Tips
#### `subDir` parameter supports following pv/pvc metadata conversion
> if `subDir` value contains following strings, it would be converted into corresponding pv/pvc name or namespace
Expand Down
6 changes: 4 additions & 2 deletions pkg/nfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
return nil, status.Errorf(codes.NotFound, "failed to create nfsSnapshot: %v", err)
}
snapVol := volumeFromSnapshot(snapshot)
if err = cs.internalMount(ctx, snapVol, nil, nil); err != nil {
if err = cs.internalMount(ctx, snapVol, req.GetParameters(), nil); err != nil {
return nil, status.Errorf(codes.Internal, "failed to mount snapshot nfs server: %v", err)
}
defer func() {
Expand All @@ -392,7 +392,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
return nil, err
}

if err = cs.internalMount(ctx, srcVol, nil, nil); err != nil {
if err = cs.internalMount(ctx, srcVol, req.GetParameters(), nil); err != nil {
return nil, status.Errorf(codes.Internal, "failed to mount src nfs server: %v", err)
}
defer func() {
Expand Down Expand Up @@ -652,6 +652,8 @@ func newNFSSnapshot(name string, params map[string]string, vol *nfsVolume) (*nfs
server = v
case paramShare:
baseDir = v
case mountOptionsField:
// no op
default:
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in snapshot storage class", k)
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/nfs/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ func TestCreateSnapshot(t *testing.T) {
req: &csi.CreateSnapshotRequest{
SourceVolumeId: "nfs-server.default.svc.cluster.local#share#subdir#src-pv-name",
Name: "snapshot-name",
Parameters: map[string]string{"mountOptions": "nfsvers=4.1,sec=sys"},
},
expResp: &csi.CreateSnapshotResponse{
Snapshot: &csi.Snapshot{
Expand All @@ -954,6 +955,15 @@ func TestCreateSnapshot(t *testing.T) {
},
expectErr: true,
},
{
desc: "create snapshot with non supported parameters",
req: &csi.CreateSnapshotRequest{
SourceVolumeId: "nfs-server.default.svc.cluster.local#share#subdir#src-pv-name",
Name: "snapshot-name",
Parameters: map[string]string{"unknown": "value"},
},
expectErr: true,
},
}
for _, test := range cases {
t.Run(test.desc, func(t *testing.T) {
Expand Down
Loading