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 }}"
|
- "--mount-permissions={{ .Values.driver.mountPermissions }}"
|
||||||
- "--working-mount-dir={{ .Values.controller.workingMountDir }}"
|
- "--working-mount-dir={{ .Values.controller.workingMountDir }}"
|
||||||
- "--default-ondelete-policy={{ .Values.controller.defaultOnDeletePolicy }}"
|
- "--default-ondelete-policy={{ .Values.controller.defaultOnDeletePolicy }}"
|
||||||
|
- "--use-tar-command-in-snapshot={{ .Values.controller.useTarCommandInSnapshot }}"
|
||||||
env:
|
env:
|
||||||
- name: NODE_ID
|
- name: NODE_ID
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
|||||||
@ -57,6 +57,7 @@ controller:
|
|||||||
runOnMaster: false
|
runOnMaster: false
|
||||||
runOnControlPlane: false
|
runOnControlPlane: false
|
||||||
enableSnapshotter: true
|
enableSnapshotter: true
|
||||||
|
useTarCommandInSnapshot: false
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
healthPort: 29652
|
healthPort: 29652
|
||||||
logLevel: 5
|
logLevel: 5
|
||||||
|
|||||||
@ -34,6 +34,7 @@ var (
|
|||||||
defaultOnDeletePolicy = flag.String("default-ondelete-policy", "", "default policy for deleting subdirectory when deleting a volume")
|
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")
|
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")
|
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() {
|
func main() {
|
||||||
@ -58,6 +59,7 @@ func handle() {
|
|||||||
DefaultOnDeletePolicy: *defaultOnDeletePolicy,
|
DefaultOnDeletePolicy: *defaultOnDeletePolicy,
|
||||||
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
|
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
|
||||||
RemoveArchivedVolumePath: *removeArchivedVolumePath,
|
RemoveArchivedVolumePath: *removeArchivedVolumePath,
|
||||||
|
UseTarCommandInSnapshot: *useTarCommandInSnapshot,
|
||||||
}
|
}
|
||||||
d := nfs.NewDriver(&driverOptions)
|
d := nfs.NewDriver(&driverOptions)
|
||||||
d.Run(false)
|
d.Run(false)
|
||||||
|
|||||||
@ -406,10 +406,15 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
|
|||||||
dstPath := filepath.Join(snapInternalVolPath, snapshot.archiveName())
|
dstPath := filepath.Join(snapInternalVolPath, snapshot.archiveName())
|
||||||
|
|
||||||
klog.V(2).Infof("tar %v -> %v", srcPath, dstPath)
|
klog.V(2).Infof("tar %v -> %v", srcPath, dstPath)
|
||||||
err = TarPack(srcPath, dstPath, true)
|
if cs.Driver.useTarCommandInSnapshot {
|
||||||
if err != nil {
|
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)
|
return nil, status.Errorf(codes.Internal, "failed to create archive for snapshot: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
klog.V(2).Infof("tar %s -> %s complete", srcPath, dstPath)
|
klog.V(2).Infof("tar %s -> %s complete", srcPath, dstPath)
|
||||||
|
|
||||||
var snapshotSize int64
|
var snapshotSize int64
|
||||||
@ -573,10 +578,15 @@ func (cs *ControllerServer) copyFromSnapshot(ctx context.Context, req *csi.Creat
|
|||||||
dstPath := getInternalVolumePath(cs.Driver.workingMountDir, dstVol)
|
dstPath := getInternalVolumePath(cs.Driver.workingMountDir, dstVol)
|
||||||
klog.V(2).Infof("copy volume from snapshot %v -> %v", snapPath, dstPath)
|
klog.V(2).Infof("copy volume from snapshot %v -> %v", snapPath, dstPath)
|
||||||
|
|
||||||
err = TarUnpack(snapPath, dstPath, true)
|
if cs.Driver.useTarCommandInSnapshot {
|
||||||
if err != nil {
|
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)
|
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)
|
klog.V(2).Infof("volume copied from snapshot %v -> %v", snapPath, dstPath)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ type DriverOptions struct {
|
|||||||
DefaultOnDeletePolicy string
|
DefaultOnDeletePolicy string
|
||||||
VolStatsCacheExpireInMinutes int
|
VolStatsCacheExpireInMinutes int
|
||||||
RemoveArchivedVolumePath bool
|
RemoveArchivedVolumePath bool
|
||||||
|
UseTarCommandInSnapshot bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Driver struct {
|
type Driver struct {
|
||||||
@ -49,6 +50,7 @@ type Driver struct {
|
|||||||
workingMountDir string
|
workingMountDir string
|
||||||
defaultOnDeletePolicy string
|
defaultOnDeletePolicy string
|
||||||
removeArchivedVolumePath bool
|
removeArchivedVolumePath bool
|
||||||
|
useTarCommandInSnapshot bool
|
||||||
|
|
||||||
//ids *identityServer
|
//ids *identityServer
|
||||||
ns *NodeServer
|
ns *NodeServer
|
||||||
@ -96,6 +98,7 @@ func NewDriver(options *DriverOptions) *Driver {
|
|||||||
workingMountDir: options.WorkingMountDir,
|
workingMountDir: options.WorkingMountDir,
|
||||||
volStatsCacheExpireInMinutes: options.VolStatsCacheExpireInMinutes,
|
volStatsCacheExpireInMinutes: options.VolStatsCacheExpireInMinutes,
|
||||||
removeArchivedVolumePath: options.RemoveArchivedVolumePath,
|
removeArchivedVolumePath: options.RemoveArchivedVolumePath,
|
||||||
|
useTarCommandInSnapshot: options.UseTarCommandInSnapshot,
|
||||||
}
|
}
|
||||||
|
|
||||||
n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
|
n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user