Skip to content

Commit 04ffb7d

Browse files
committed
fix: delete volume failure due to permission issue
1 parent 902fe90 commit 04ffb7d

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"
@@ -232,6 +233,14 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
232233
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err)
233234
}
234235
} else {
236+
if _, err := os.Lstat(internalVolumePath); err == nil {
237+
if err2 := filepath.WalkDir(internalVolumePath, func(path string, _ fs.DirEntry, _ error) error {
238+
return os.Chmod(path, 0777)
239+
}); err2 != nil {
240+
klog.Errorf("failed to chmod subdirectory: %v", err2)
241+
}
242+
}
243+
235244
rootDir := getRootDir(smbVol.subDir)
236245
if rootDir != "" {
237246
rootDir = filepath.Join(getInternalMountPath(d.workingMountDir, smbVol), rootDir)

0 commit comments

Comments
 (0)