Skip to content

Commit e110f3d

Browse files
authored
Merge pull request #840 from mpatlasov/Chmod-volume-before-deletion
fix: chmod volume dir before deletion
2 parents d4481b1 + 894bd02 commit e110f3d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/smb/controllerserver.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package smb
1919
import (
2020
"context"
2121
"fmt"
22+
"io/fs"
2223
"os"
2324
"os/exec"
2425
"path/filepath"
@@ -223,6 +224,14 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
223224
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
224225
}
225226
} else {
227+
if _, err2 := os.Lstat(internalVolumePath); err2 == nil {
228+
err2 := filepath.WalkDir(internalVolumePath, func(path string, di fs.DirEntry, err error) error {
229+
return os.Chmod(path, 0777)
230+
})
231+
if err2 != nil {
232+
klog.Errorf("failed to chmod subdirectory: %v", err2)
233+
}
234+
}
226235
klog.V(2).Infof("Removing subdirectory at %v", internalVolumePath)
227236
if err = os.RemoveAll(internalVolumePath); err != nil {
228237
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())

0 commit comments

Comments
 (0)