@@ -34,7 +34,6 @@ import (
3434
3535 "github.com/container-storage-interface/spec/lib/go/csi"
3636 "k8s.io/klog/v2"
37- utilexec "k8s.io/utils/exec"
3837
3938 "github.com/kubernetes-csi/csi-driver-host-path/pkg/state"
4039)
@@ -543,21 +542,10 @@ func (hp *hostPath) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotR
543542
544543 snapshotID := uuid .NewUUID ().String ()
545544 creationTime := ptypes .TimestampNow ()
546- volPath := hostPathVolume .VolPath
547545 file := hp .getSnapshotPath (snapshotID )
548546
549- var cmd []string
550- if hostPathVolume .VolAccessType == state .BlockAccess {
551- glog .V (4 ).Infof ("Creating snapshot of Raw Block Mode Volume" )
552- cmd = []string {"cp" , volPath , file }
553- } else {
554- glog .V (4 ).Infof ("Creating snapshot of Filsystem Mode Volume" )
555- cmd = []string {"tar" , "czf" , file , "-C" , volPath , "." }
556- }
557- executor := utilexec .New ()
558- out , err := executor .Command (cmd [0 ], cmd [1 :]... ).CombinedOutput ()
559- if err != nil {
560- return nil , fmt .Errorf ("failed create snapshot: %w: %s" , err , out )
547+ if err := hp .createSnapshotFromVolume (hostPathVolume , file ); err != nil {
548+ return nil , err
561549 }
562550
563551 glog .V (4 ).Infof ("create volume snapshot %s" , file )
0 commit comments