fix: disable archiving InternalVolumePath by default

fix
This commit is contained in:
andyzhangx 2024-08-28 09:56:58 +00:00
parent 25000908c1
commit ab06ad33ac
6 changed files with 20 additions and 11 deletions

View File

@ -7,7 +7,7 @@ image:
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
csiProvisioner: csiProvisioner:
repository: registry.k8s.io/sig-storage/csi-provisioner repository: registry.k8s.io/sig-storage/csi-provisioner
tag: v5.0.1 tag: v5.0.2
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
csiSnapshotter: csiSnapshotter:
repository: registry.k8s.io/sig-storage/csi-snapshotter repository: registry.k8s.io/sig-storage/csi-snapshotter

View File

@ -33,6 +33,7 @@ var (
workingMountDir = flag.String("working-mount-dir", "/tmp", "working directory for provisioner to mount nfs shares temporarily") workingMountDir = flag.String("working-mount-dir", "/tmp", "working directory for provisioner to mount nfs shares temporarily")
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", true, "remove archived volume path in DeleteVolume")
) )
func main() { func main() {
@ -56,6 +57,7 @@ func handle() {
WorkingMountDir: *workingMountDir, WorkingMountDir: *workingMountDir,
DefaultOnDeletePolicy: *defaultOnDeletePolicy, DefaultOnDeletePolicy: *defaultOnDeletePolicy,
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes, VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
RemoveArchivedVolumePath: *removeArchivedVolumePath,
} }
d := nfs.NewDriver(&driverOptions) d := nfs.NewDriver(&driverOptions)
d.Run(false) d.Run(false)

View File

@ -35,7 +35,7 @@ spec:
effect: "NoSchedule" effect: "NoSchedule"
containers: containers:
- name: csi-provisioner - name: csi-provisioner
image: registry.k8s.io/sig-storage/csi-provisioner:v5.0.1 image: registry.k8s.io/sig-storage/csi-provisioner:v5.0.2
args: args:
- "-v=2" - "-v=2"
- "--csi-address=$(ADDRESS)" - "--csi-address=$(ADDRESS)"

View File

@ -255,8 +255,12 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
// archive subdirectory under base-dir, remove stale archived copy if exists. // archive subdirectory under base-dir, remove stale archived copy if exists.
klog.V(2).Infof("archiving subdirectory %s --> %s", internalVolumePath, archivedInternalVolumePath) klog.V(2).Infof("archiving subdirectory %s --> %s", internalVolumePath, archivedInternalVolumePath)
if err = os.RemoveAll(archivedInternalVolumePath); err != nil { if cs.Driver.removeArchivedVolumePath {
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error()) klog.V(2).Infof("removing archived subdirectory at %v", archivedInternalVolumePath)
if err = os.RemoveAll(archivedInternalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error())
}
klog.V(2).Infof("removed archived subdirectory at %v", archivedInternalVolumePath)
} }
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil { if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error()) return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())

View File

@ -37,16 +37,18 @@ type DriverOptions struct {
WorkingMountDir string WorkingMountDir string
DefaultOnDeletePolicy string DefaultOnDeletePolicy string
VolStatsCacheExpireInMinutes int VolStatsCacheExpireInMinutes int
RemoveArchivedVolumePath bool
} }
type Driver struct { type Driver struct {
name string name string
nodeID string nodeID string
version string version string
endpoint string endpoint string
mountPermissions uint64 mountPermissions uint64
workingMountDir string workingMountDir string
defaultOnDeletePolicy string defaultOnDeletePolicy string
removeArchivedVolumePath bool
//ids *identityServer //ids *identityServer
ns *NodeServer ns *NodeServer
@ -91,6 +93,7 @@ func NewDriver(options *DriverOptions) *Driver {
mountPermissions: options.MountPermissions, mountPermissions: options.MountPermissions,
workingMountDir: options.WorkingMountDir, workingMountDir: options.WorkingMountDir,
volStatsCacheExpireInMinutes: options.VolStatsCacheExpireInMinutes, volStatsCacheExpireInMinutes: options.VolStatsCacheExpireInMinutes,
removeArchivedVolumePath: options.RemoveArchivedVolumePath,
} }
n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{