@@ -78,18 +78,10 @@ type nfsSnapshot struct {
78
78
src string
79
79
}
80
80
81
- func (snap nfsSnapshot ) archiveSubPath () string {
82
- return snap .uuid
83
- }
84
-
85
81
func (snap nfsSnapshot ) archiveName () string {
86
82
return fmt .Sprintf ("%v.tar.gz" , snap .src )
87
83
}
88
84
89
- func (snap nfsSnapshot ) archivePath () string {
90
- return filepath .Join (snap .archiveSubPath (), snap .archiveName ())
91
- }
92
-
93
85
// Ordering of elements in the CSI volume id.
94
86
// ID is of the form {server}/{baseDir}/{subDir}.
95
87
// TODO: This volume id format limits baseDir and
@@ -331,7 +323,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
331
323
klog .Warningf ("failed to unmount snapshot nfs server: %v" , err )
332
324
}
333
325
}()
334
- snapInternalVolPath := filepath . Join ( getInternalVolumePath (cs .Driver .workingMountDir , snapVol ), snapshot . archiveSubPath () )
326
+ snapInternalVolPath := getInternalVolumePath (cs .Driver .workingMountDir , snapVol )
335
327
if err = os .MkdirAll (snapInternalVolPath , 0777 ); err != nil {
336
328
return nil , status .Errorf (codes .Internal , "failed to make subdirectory: %v" , err )
337
329
}
@@ -409,7 +401,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
409
401
}()
410
402
411
403
// delete snapshot archive
412
- internalVolumePath := filepath . Join ( getInternalVolumePath (cs .Driver .workingMountDir , vol ), snap . archiveSubPath () )
404
+ internalVolumePath := getInternalVolumePath (cs .Driver .workingMountDir , vol )
413
405
klog .V (2 ).Infof ("Removing snapshot archive at %v" , internalVolumePath )
414
406
if err = os .RemoveAll (internalVolumePath ); err != nil {
415
407
return nil , status .Errorf (codes .Internal , "failed to delete subdirectory: %v" , err .Error ())
@@ -503,7 +495,7 @@ func (cs *ControllerServer) copyFromSnapshot(ctx context.Context, req *csi.Creat
503
495
}()
504
496
505
497
// untar snapshot archive to dst path
506
- snapPath := filepath .Join (getInternalVolumePath (cs .Driver .workingMountDir , snapVol ), snap .archivePath ())
498
+ snapPath := filepath .Join (getInternalVolumePath (cs .Driver .workingMountDir , snapVol ), snap .archiveName ())
507
499
dstPath := getInternalVolumePath (cs .Driver .workingMountDir , dstVol )
508
500
klog .V (2 ).Infof ("copy volume from snapshot %v -> %v" , snapPath , dstPath )
509
501
out , err := exec .Command ("tar" , "-xzvf" , snapPath , "-C" , dstPath ).CombinedOutput ()
@@ -803,7 +795,7 @@ func volumeFromSnapshot(snap *nfsSnapshot) *nfsVolume {
803
795
id : snap .id ,
804
796
server : snap .server ,
805
797
baseDir : snap .baseDir ,
806
- subDir : snap .baseDir ,
798
+ subDir : snap .uuid ,
807
799
uuid : snap .uuid ,
808
800
}
809
801
}
0 commit comments