Merge pull request #842 from andyzhangx/useTarCommandInSnapshot
feat: add useTarCommandInSnapshot flag in chart config
This commit is contained in:
commit
13fef84502
Binary file not shown.
@ -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:
|
||||
|
||||
@ -57,6 +57,7 @@ controller:
|
||||
runOnMaster: false
|
||||
runOnControlPlane: false
|
||||
enableSnapshotter: true
|
||||
useTarCommandInSnapshot: false
|
||||
livenessProbe:
|
||||
healthPort: 29652
|
||||
logLevel: 5
|
||||
|
||||
@ -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() {
|
||||
@ -58,6 +59,7 @@ func handle() {
|
||||
DefaultOnDeletePolicy: *defaultOnDeletePolicy,
|
||||
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
|
||||
RemoveArchivedVolumePath: *removeArchivedVolumePath,
|
||||
UseTarCommandInSnapshot: *useTarCommandInSnapshot,
|
||||
}
|
||||
d := nfs.NewDriver(&driverOptions)
|
||||
d.Run(false)
|
||||
|
||||
@ -406,10 +406,15 @@ 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 {
|
||||
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)
|
||||
|
||||
var snapshotSize int64
|
||||
@ -573,10 +578,15 @@ 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 {
|
||||
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
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ type DriverOptions struct {
|
||||
DefaultOnDeletePolicy string
|
||||
VolStatsCacheExpireInMinutes int
|
||||
RemoveArchivedVolumePath bool
|
||||
UseTarCommandInSnapshot bool
|
||||
}
|
||||
|
||||
type Driver struct {
|
||||
@ -49,6 +50,7 @@ type Driver struct {
|
||||
workingMountDir string
|
||||
defaultOnDeletePolicy string
|
||||
removeArchivedVolumePath bool
|
||||
useTarCommandInSnapshot bool
|
||||
|
||||
//ids *identityServer
|
||||
ns *NodeServer
|
||||
@ -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{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user