diff --git a/charts/v4.8.0/csi-driver-nfs-v4.8.0.tgz b/charts/v4.8.0/csi-driver-nfs-v4.8.0.tgz index 85955234..f88a7702 100644 Binary files a/charts/v4.8.0/csi-driver-nfs-v4.8.0.tgz and b/charts/v4.8.0/csi-driver-nfs-v4.8.0.tgz differ diff --git a/charts/v4.8.0/csi-driver-nfs/values.yaml b/charts/v4.8.0/csi-driver-nfs/values.yaml index e0d4aada..77900585 100644 --- a/charts/v4.8.0/csi-driver-nfs/values.yaml +++ b/charts/v4.8.0/csi-driver-nfs/values.yaml @@ -7,7 +7,7 @@ image: pullPolicy: IfNotPresent csiProvisioner: repository: registry.k8s.io/sig-storage/csi-provisioner - tag: v5.0.1 + tag: v5.0.2 pullPolicy: IfNotPresent csiSnapshotter: repository: registry.k8s.io/sig-storage/csi-snapshotter diff --git a/cmd/nfsplugin/main.go b/cmd/nfsplugin/main.go index cf55eb95..2bc088be 100644 --- a/cmd/nfsplugin/main.go +++ b/cmd/nfsplugin/main.go @@ -33,6 +33,7 @@ var ( 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") 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") ) func main() { @@ -56,6 +57,7 @@ func handle() { WorkingMountDir: *workingMountDir, DefaultOnDeletePolicy: *defaultOnDeletePolicy, VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes, + RemoveArchivedVolumePath: *removeArchivedVolumePath, } d := nfs.NewDriver(&driverOptions) d.Run(false) diff --git a/deploy/v4.8.0/csi-nfs-controller.yaml b/deploy/v4.8.0/csi-nfs-controller.yaml index 0237043f..57ca1ab4 100644 --- a/deploy/v4.8.0/csi-nfs-controller.yaml +++ b/deploy/v4.8.0/csi-nfs-controller.yaml @@ -35,7 +35,7 @@ spec: effect: "NoSchedule" containers: - 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: - "-v=2" - "--csi-address=$(ADDRESS)" diff --git a/pkg/nfs/controllerserver.go b/pkg/nfs/controllerserver.go index cb72c1de..d041e641 100644 --- a/pkg/nfs/controllerserver.go +++ b/pkg/nfs/controllerserver.go @@ -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. klog.V(2).Infof("archiving subdirectory %s --> %s", internalVolumePath, archivedInternalVolumePath) - if err = os.RemoveAll(archivedInternalVolumePath); err != nil { - return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error()) + if cs.Driver.removeArchivedVolumePath { + 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 { return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error()) diff --git a/pkg/nfs/nfs.go b/pkg/nfs/nfs.go index 7d69265e..eec8ea75 100644 --- a/pkg/nfs/nfs.go +++ b/pkg/nfs/nfs.go @@ -37,16 +37,18 @@ type DriverOptions struct { WorkingMountDir string DefaultOnDeletePolicy string VolStatsCacheExpireInMinutes int + RemoveArchivedVolumePath bool } type Driver struct { - name string - nodeID string - version string - endpoint string - mountPermissions uint64 - workingMountDir string - defaultOnDeletePolicy string + name string + nodeID string + version string + endpoint string + mountPermissions uint64 + workingMountDir string + defaultOnDeletePolicy string + removeArchivedVolumePath bool //ids *identityServer ns *NodeServer @@ -91,6 +93,7 @@ func NewDriver(options *DriverOptions) *Driver { mountPermissions: options.MountPermissions, workingMountDir: options.WorkingMountDir, volStatsCacheExpireInMinutes: options.VolStatsCacheExpireInMinutes, + removeArchivedVolumePath: options.RemoveArchivedVolumePath, } n.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{