Skip to content

Commit

Permalink
Merge pull request #851 from andyzhangx/fix-delete-volume-permission
Browse files Browse the repository at this point in the history
fix: delete volume failure due to permission issue
  • Loading branch information
andyzhangx authored Sep 17, 2024
2 parents 902fe90 + 04ffb7d commit 68c09ad
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/smb/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package smb
import (
"context"
"fmt"
"io/fs"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -232,6 +233,14 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err)
}
} else {
if _, err := os.Lstat(internalVolumePath); err == nil {
if err2 := filepath.WalkDir(internalVolumePath, func(path string, _ fs.DirEntry, _ error) error {
return os.Chmod(path, 0777)
}); err2 != nil {
klog.Errorf("failed to chmod subdirectory: %v", err2)
}
}

rootDir := getRootDir(smbVol.subDir)
if rootDir != "" {
rootDir = filepath.Join(getInternalMountPath(d.workingMountDir, smbVol), rootDir)
Expand Down

0 comments on commit 68c09ad

Please sign in to comment.