@@ -170,7 +170,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
170
170
switch volumeSource .Type .(type ) {
171
171
case * csi.VolumeContentSource_Snapshot :
172
172
if snapshot := volumeSource .GetSnapshot (); snapshot != nil {
173
- err = loadFromSnapshot (capacity , snapshot .GetSnapshotId (), path )
173
+ err = loadFromSnapshot (capacity , snapshot .GetSnapshotId (), path , requestedAccessType )
174
174
vol .ParentSnapID = snapshot .GetSnapshotId ()
175
175
}
176
176
case * csi.VolumeContentSource_Volume :
@@ -282,7 +282,7 @@ func (cs *controllerServer) ListVolumes(ctx context.Context, req *csi.ListVolume
282
282
283
283
// getSnapshotPath returns the full path to where the snapshot is stored
284
284
func getSnapshotPath (snapshotId string ) string {
285
- return filepath .Join (dataRoot , fmt .Sprintf ("%s.tgz " , snapshotId ))
285
+ return filepath .Join (dataRoot , fmt .Sprintf ("%s.snap " , snapshotId ))
286
286
}
287
287
288
288
// 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
331
331
creationTime := ptypes .TimestampNow ()
332
332
volPath := hostPathVolume .VolPath
333
333
file := getSnapshotPath (snapshotID )
334
- args := []string {}
334
+
335
+ var cmd []string
335
336
if hostPathVolume .VolAccessType == blockAccess {
336
337
glog .V (4 ).Infof ("Creating snapshot of Raw Block Mode Volume" )
337
- args = []string {"czf " , file , volPath }
338
+ cmd = []string {"cp " , volPath , file }
338
339
} else {
339
340
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 , "." }
341
342
}
342
343
executor := utilexec .New ()
343
- out , err := executor .Command ("tar" , args ... ).CombinedOutput ()
344
+ out , err := executor .Command (cmd [ 0 ], cmd [ 1 :] ... ).CombinedOutput ()
344
345
if err != nil {
345
346
return nil , status .Errorf (codes .Internal , "failed create snapshot: %v: %s" , err , out )
346
347
}
0 commit comments