@@ -170,7 +170,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
170170 switch volumeSource .Type .(type ) {
171171 case * csi.VolumeContentSource_Snapshot :
172172 if snapshot := volumeSource .GetSnapshot (); snapshot != nil {
173- err = loadFromSnapshot (capacity , snapshot .GetSnapshotId (), path )
173+ err = loadFromSnapshot (capacity , snapshot .GetSnapshotId (), path , requestedAccessType )
174174 vol .ParentSnapID = snapshot .GetSnapshotId ()
175175 }
176176 case * csi.VolumeContentSource_Volume :
@@ -282,7 +282,7 @@ func (cs *controllerServer) ListVolumes(ctx context.Context, req *csi.ListVolume
282282
283283// getSnapshotPath returns the full path to where the snapshot is stored
284284func getSnapshotPath (snapshotId string ) string {
285- return filepath .Join (dataRoot , fmt .Sprintf ("%s.tgz " , snapshotId ))
285+ return filepath .Join (dataRoot , fmt .Sprintf ("%s.snap " , snapshotId ))
286286}
287287
288288// CreateSnapshot uses tar command to create snapshot for hostpath volume. The tar command can quickly create
@@ -331,16 +331,17 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
331331 creationTime := ptypes .TimestampNow ()
332332 volPath := hostPathVolume .VolPath
333333 file := getSnapshotPath (snapshotID )
334- args := []string {}
334+
335+ var cmd []string
335336 if hostPathVolume .VolAccessType == blockAccess {
336337 glog .V (4 ).Infof ("Creating snapshot of Raw Block Mode Volume" )
337- args = []string {"czf " , file , volPath }
338+ cmd = []string {"cp " , volPath , file }
338339 } else {
339340 glog .V (4 ).Infof ("Creating snapshot of Filsystem Mode Volume" )
340- args = []string {"czf" , file , "-C" , volPath , "." }
341+ cmd = []string {"tar" , "czf" , file , "-C" , volPath , "." }
341342 }
342343 executor := utilexec .New ()
343- out , err := executor .Command ("tar" , args ... ).CombinedOutput ()
344+ out , err := executor .Command (cmd [ 0 ], cmd [ 1 :] ... ).CombinedOutput ()
344345 if err != nil {
345346 return nil , status .Errorf (codes .Internal , "failed create snapshot: %v: %s" , err , out )
346347 }
0 commit comments