Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: chmod volume dir before deletion #840

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to pass -o dir_mode=0777,file_mode=0777 in internalMount() above? It would fix any potential RemoveAll in the archive too and who knows what else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for pointing out!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a fix here: #843

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andyzhangx , @jsafrane I jumped the gun saying 0777 makes sense. It doesn't help practically. See please my comment here: #843 (comment)

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
Loading