Skip to content

Commit a140434

Browse files
committed
feat: inherit snapshot nfs server params from src vol
1 parent 9cad732 commit a140434

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/nfs/controllerserver.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
289289
return nil, status.Error(codes.InvalidArgument, "CreateSnapshot name must be provided")
290290
}
291291

292-
snapshot, err := newNFSSnapshot(req.GetName(), req.GetParameters())
292+
srcVol, err := getNfsVolFromID(req.GetSourceVolumeId())
293+
if err != nil {
294+
return nil, status.Errorf(codes.NotFound, "failed to create source volume: %v", err)
295+
}
296+
snapshot, err := newNFSSnapshot(req.GetName(), req.GetParameters(), srcVol)
293297
if err != nil {
294298
return nil, status.Errorf(codes.NotFound, "failed to create nfsSnapshot: %v", err)
295299
}
@@ -303,10 +307,6 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
303307
}
304308
}()
305309

306-
srcVol, err := getNfsVolFromID(req.GetSourceVolumeId())
307-
if err != nil {
308-
return nil, status.Errorf(codes.NotFound, "failed to create source volume: %v", err)
309-
}
310310
if err = cs.internalMount(ctx, srcVol, nil, nil); err != nil {
311311
return nil, status.Errorf(codes.Internal, "failed to mount src nfs server: %v", err)
312312
}
@@ -545,8 +545,9 @@ func (cs *ControllerServer) copyVolume(ctx context.Context, req *csi.CreateVolum
545545
}
546546

547547
// newNFSSnapshot Convert VolumeSnapshot parameters to a nfsSnapshot
548-
func newNFSSnapshot(name string, params map[string]string) (*nfsSnapshot, error) {
549-
var server, baseDir string
548+
func newNFSSnapshot(name string, params map[string]string, vol nfsVolume) (*nfsSnapshot, error) {
549+
server := vol.server
550+
baseDir := vol.baseDir
550551
for k, v := range params {
551552
switch strings.ToLower(k) {
552553
case paramServer:

0 commit comments

Comments
 (0)