Skip to content

Commit a12ac11

Browse files
Merge pull request #14 from mpatlasov/OCPBUGS-39303-fix-cleanup-issue
OCPBUGS-39303: UPSTREAM: 851: fix: delete volume failure due to permission issue
2 parents 0ab8c37 + 560db72 commit a12ac11

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 _, err := os.Lstat(internalVolumePath); err == nil {
228+
if err2 := filepath.WalkDir(internalVolumePath, func(path string, _ fs.DirEntry, _ error) error {
229+
return os.Chmod(path, 0777)
230+
}); err2 != nil {
231+
klog.Errorf("failed to chmod subdirectory: %v", err2)
232+
}
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)