Skip to content

Commit

Permalink
Merge pull request #840 from mpatlasov/Chmod-volume-before-deletion
Browse files Browse the repository at this point in the history
fix: chmod volume dir before deletion
  • Loading branch information
k8s-ci-robot authored Sep 5, 2024
2 parents d4481b1 + 894bd02 commit e110f3d
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 @@ -223,6 +224,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.Error())
}
} else {
if _, err2 := os.Lstat(internalVolumePath); err2 == nil {
err2 := filepath.WalkDir(internalVolumePath, func(path string, di fs.DirEntry, err error) error {
return os.Chmod(path, 0777)
})
if err2 != nil {
klog.Errorf("failed to chmod subdirectory: %v", err2)
}
}
klog.V(2).Infof("Removing subdirectory at %v", internalVolumePath)
if err = os.RemoveAll(internalVolumePath); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())
Expand Down

0 comments on commit e110f3d

Please sign in to comment.