Skip to content

Commit d20999f

Browse files
Fixed the Raw Block PV snapshot support
1 parent a6ba7d0 commit d20999f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

deploy/kubernetes-1.13/hostpath/csi-hostpath-plugin.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ spec:
9999
- mountPath: /var/lib/kubelet/plugins
100100
mountPropagation: Bidirectional
101101
name: plugins-dir
102+
- mountPath: /csi-data-dir
103+
name: csi-data-dir
102104

103105
- name: liveness-probe
104106
volumeMounts:

pkg/hostpath/controllerserver.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import (
3838

3939
const (
4040
deviceID = "deviceID"
41-
provisionRoot = "/csi-data-dir"
42-
snapshotRoot = "/csi-data-dir"
41+
provisionRoot = "/csi-data-dir/"
42+
snapshotRoot = "/csi-data-dir/"
4343
maxStorageCapacity = tib
4444
)
4545

@@ -347,7 +347,14 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
347347
creationTime := ptypes.TimestampNow()
348348
volPath := hostPathVolume.VolPath
349349
file := snapshotRoot + snapshotID + ".tgz"
350-
args := []string{"czf", file, "-C", volPath, "."}
350+
args := []string{}
351+
if hostPathVolume.VolAccessType == blockAccess {
352+
glog.V(4).Infof("Creating snapshot of Raw Block Mode Volume")
353+
args = []string{"czf", file, volPath}
354+
} else {
355+
glog.V(4).Infof("Creating snapshot of Filsystem Mode Volume")
356+
args = []string{"czf", file, "-C", volPath, "."}
357+
}
351358
executor := utilexec.New()
352359
out, err := executor.Command("tar", args...).CombinedOutput()
353360
if err != nil {

0 commit comments

Comments
 (0)