@@ -289,7 +289,11 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
289
289
return nil , status .Error (codes .InvalidArgument , "CreateSnapshot name must be provided" )
290
290
}
291
291
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 )
293
297
if err != nil {
294
298
return nil , status .Errorf (codes .NotFound , "failed to create nfsSnapshot: %v" , err )
295
299
}
@@ -303,10 +307,6 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
303
307
}
304
308
}()
305
309
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
- }
310
310
if err = cs .internalMount (ctx , srcVol , nil , nil ); err != nil {
311
311
return nil , status .Errorf (codes .Internal , "failed to mount src nfs server: %v" , err )
312
312
}
@@ -545,8 +545,9 @@ func (cs *ControllerServer) copyVolume(ctx context.Context, req *csi.CreateVolum
545
545
}
546
546
547
547
// 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
550
551
for k , v := range params {
551
552
switch strings .ToLower (k ) {
552
553
case paramServer :
0 commit comments