diff options
| author | chrislusf <chris.lu@gmail.com> | 2025-12-03 19:36:35 -0800 |
|---|---|---|
| committer | chrislusf <chris.lu@gmail.com> | 2025-12-03 19:36:35 -0800 |
| commit | a0500b8a994235079337599ba6ebdc598a671abf (patch) | |
| tree | 647a3bddb1383926f0f7907aaed0f36982023a78 /pkg/driver/mount_util.go | |
| parent | 454b9651450a8feecf5896ce3b2526a442a73e33 (diff) | |
| download | seaweedfs-csi-driver-a0500b8a994235079337599ba6ebdc598a671abf.tar.xz seaweedfs-csi-driver-a0500b8a994235079337599ba6ebdc598a671abf.zip | |
refactor: address code review feedback
- Handle unexpected stat errors in cleanupStaleStagingPath (high priority)
- Extract staging logic into stageNewVolume helper method for reuse
- Extract isReadOnlyAccessMode helper to avoid duplicated read-only checks
- Remove redundant mountutil.Unmount call (CleanupMountPoint already handles it)
Diffstat (limited to 'pkg/driver/mount_util.go')
| -rw-r--r-- | pkg/driver/mount_util.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/driver/mount_util.go b/pkg/driver/mount_util.go index 049d4dc..200817d 100644 --- a/pkg/driver/mount_util.go +++ b/pkg/driver/mount_util.go @@ -83,10 +83,14 @@ func cleanupStaleStagingPath(stagingPath string) error { // If stat fails with a different error (like corrupted mount), try force cleanup if mount.IsCorruptedMnt(err) { // Force unmount for corrupted mounts - if err := mount.CleanupMountPoint(stagingPath, mountutil, true); err != nil { - glog.Warningf("failed to cleanup corrupted mount point %s: %v", stagingPath, err) - return err + if cleanupErr := mount.CleanupMountPoint(stagingPath, mountutil, true); cleanupErr != nil { + glog.Warningf("failed to cleanup corrupted mount point %s: %v", stagingPath, cleanupErr) + return cleanupErr } + } else { + // stat failed with an unexpected error, return it + glog.Warningf("stat on staging path %s failed during cleanup: %v", stagingPath, err) + return err } } |
