Skip to content

Commit

Permalink
fix: disable archiving InternalVolumePath by default
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
andyzhangx committed Aug 28, 2024
1 parent 2500090 commit ab06ad3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
Binary file modified charts/v4.8.0/csi-driver-nfs-v4.8.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion charts/v4.8.0/csi-driver-nfs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cmd/nfsplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", true, "remove archived volume path in DeleteVolume")
)

func main() {
Expand All @@ -56,6 +57,7 @@ func handle() {
WorkingMountDir: *workingMountDir,
DefaultOnDeletePolicy: *defaultOnDeletePolicy,
VolStatsCacheExpireInMinutes: *volStatsCacheExpireInMinutes,
RemoveArchivedVolumePath: *removeArchivedVolumePath,
}
d := nfs.NewDriver(&driverOptions)
d.Run(false)
Expand Down
2 changes: 1 addition & 1 deletion deploy/v4.8.0/csi-nfs-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
8 changes: 6 additions & 2 deletions pkg/nfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
17 changes: 10 additions & 7 deletions pkg/nfs/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit ab06ad3

Please sign in to comment.