Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified charts/latest/csi-driver-nfs-v0.0.0.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ spec:
- "--mount-permissions={{ .Values.driver.mountPermissions }}"
- "--working-mount-dir={{ .Values.controller.workingMountDir }}"
- "--default-ondelete-policy={{ .Values.controller.defaultOnDeletePolicy }}"
- "--use-tar-command-in-snapshot={{ .Values.controller.useTarCommandInSnapshot }}"
env:
- name: NODE_ID
valueFrom:
Expand Down
1 change: 1 addition & 0 deletions charts/latest/csi-driver-nfs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ controller:
runOnMaster: false
runOnControlPlane: false
enableSnapshotter: true
useTarCommandInSnapshot: false
livenessProbe:
healthPort: 29652
logLevel: 5
Expand Down
2 changes: 2 additions & 0 deletions cmd/nfsplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
defaultOnDeletePolicy = flag.String("default-ondelete-policy", "", "default policy for deleting subdirectory when deleting a volume")
volStatsCacheExpireInMinutes = flag.Int("vol-stats-cache-expire-in-minutes", 10, "The cache expire time in minutes for volume stats cache")
removeArchivedVolumePath = flag.Bool("remove-archived-volume-path", false, "remove archived volume path in DeleteVolume")
useTarCommandInSnapshot = flag.Bool("use-tar-command-in-snapshot", false, "use tar command to pack and unpack snapshot data")
)

func main() {
Expand All @@ -58,6 +59,7 @@ func handle() {
DefaultOnDeletePolicy: *defaultOnDeletePolicy,
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
RemoveArchivedVolumePath: *removeArchivedVolumePath,
UseTarCommandInSnapshot: *useTarCommandInSnapshot,
}
d := nfs.NewDriver(&driverOptions)
d.Run(false)
Expand Down
22 changes: 16 additions & 6 deletions pkg/nfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,14 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
dstPath := filepath.Join(snapInternalVolPath, snapshot.archiveName())

klog.V(2).Infof("tar %v -> %v", srcPath, dstPath)
err = TarPack(srcPath, dstPath, true)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to create archive for snapshot: %v", err)
if cs.Driver.useTarCommandInSnapshot {
if out, err := exec.Command("tar", "-C", srcPath, "-czvf", dstPath, ".").CombinedOutput(); err != nil {
return nil, status.Errorf(codes.Internal, "failed to create archive for snapshot: %v: %v", err, string(out))
}
} else {
if err := TarPack(srcPath, dstPath, true); err != nil {
return nil, status.Errorf(codes.Internal, "failed to create archive for snapshot: %v", err)
}
}
klog.V(2).Infof("tar %s -> %s complete", srcPath, dstPath)

Expand Down Expand Up @@ -573,9 +578,14 @@ func (cs *ControllerServer) copyFromSnapshot(ctx context.Context, req *csi.Creat
dstPath := getInternalVolumePath(cs.Driver.workingMountDir, dstVol)
klog.V(2).Infof("copy volume from snapshot %v -> %v", snapPath, dstPath)

err = TarUnpack(snapPath, dstPath, true)
if err != nil {
return status.Errorf(codes.Internal, "failed to copy volume for snapshot: %v", err)
if cs.Driver.useTarCommandInSnapshot {
if out, err := exec.Command("tar", "-xzvf", snapPath, "-C", dstPath).CombinedOutput(); err != nil {
return status.Errorf(codes.Internal, "failed to copy volume for snapshot: %v: %v", err, string(out))
}
} else {
if err := TarUnpack(snapPath, dstPath, true); err != nil {
return status.Errorf(codes.Internal, "failed to copy volume for snapshot: %v", err)
}
}
klog.V(2).Infof("volume copied from snapshot %v -> %v", snapPath, dstPath)
return nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/nfs/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type DriverOptions struct {
DefaultOnDeletePolicy string
VolStatsCacheExpireInMinutes int
RemoveArchivedVolumePath bool
UseTarCommandInSnapshot bool
}

type Driver struct {
Expand All @@ -49,6 +50,7 @@ type Driver struct {
workingMountDir string
defaultOnDeletePolicy string
removeArchivedVolumePath bool
useTarCommandInSnapshot bool

//ids *identityServer
ns *NodeServer
Expand Down Expand Up @@ -96,6 +98,7 @@ func NewDriver(options *DriverOptions) *Driver {
workingMountDir: options.WorkingMountDir,
volStatsCacheExpireInMinutes: options.VolStatsCacheExpireInMinutes,
removeArchivedVolumePath: options.RemoveArchivedVolumePath,
useTarCommandInSnapshot: options.UseTarCommandInSnapshot,
}

n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
Expand Down
Loading