Skip to content

Commit 560db72

Browse files
andyzhangxmpatlasov
authored andcommitted
UPSTREAM: 851: fix: delete volume failure due to permission issue
1 parent 0161a3a commit 560db72

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"
@@ -198,6 +199,14 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
198199
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
199200
}
200201
} else {
202+
if _, err := os.Lstat(internalVolumePath); err == nil {
203+
if err2 := filepath.WalkDir(internalVolumePath, func(path string, _ fs.DirEntry, _ error) error {
204+
return os.Chmod(path, 0777)
205+
}); err2 != nil {
206+
klog.Errorf("failed to chmod subdirectory: %v", err2)
207+
}
208+
}
209+
201210
klog.V(2).Infof("Removing subdirectory at %v", internalVolumePath)
202211
if err = os.RemoveAll(internalVolumePath); err != nil {
203212
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())

0 commit comments

Comments
 (0)