@@ -34,7 +34,6 @@ import (
34
34
35
35
"github.com/container-storage-interface/spec/lib/go/csi"
36
36
"k8s.io/klog/v2"
37
- utilexec "k8s.io/utils/exec"
38
37
39
38
"github.com/kubernetes-csi/csi-driver-host-path/pkg/state"
40
39
)
@@ -543,21 +542,10 @@ func (hp *hostPath) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotR
543
542
544
543
snapshotID := uuid .NewUUID ().String ()
545
544
creationTime := ptypes .TimestampNow ()
546
- volPath := hostPathVolume .VolPath
547
545
file := hp .getSnapshotPath (snapshotID )
548
546
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
561
549
}
562
550
563
551
glog .V (4 ).Infof ("create volume snapshot %s" , file )
0 commit comments