Skip to content

Commit a531ba4

Browse files
SMBMount: return error when getRootMappingPath fails
1 parent cb1fdba commit a531ba4

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

pkg/mounter/safe_mounter_windows.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,11 @@ func (mounter *csiProxyMounter) SMBMount(source, target, fsType string, mountOpt
105105
source = strings.TrimSuffix(source, "\\")
106106
}
107107

108-
// Try to lock `mappingPath`. We avoid throwing any exception to backward compatibility.
109-
unlock := func() {}
110108
mappingPath, err := getRootMappingPath(source)
111109
if err != nil {
112-
klog.Warningf("getRootMappingPath(%s) failed with %v", source, err)
113-
} else {
114-
unlock = lock(mappingPath)
110+
return fmt.Errorf("getRootMappingPath(%s) failed with %v", source, err)
115111
}
112+
unlock := lock(mappingPath)
116113
defer unlock()
117114

118115
normalizedTarget := normalizeWindowsPath(target)
@@ -128,12 +125,8 @@ func (mounter *csiProxyMounter) SMBMount(source, target, fsType string, mountOpt
128125
}
129126
klog.V(2).Infof("mount %s on %s successfully", source, normalizedTarget)
130127

131-
if mappingPath != "" {
132-
// When mount successful tries to increment mapping reference count.
133-
err = incementRemotePathReferencesCount(mappingPath, source)
134-
if err != nil {
135-
klog.Warningf("incementMappingPathCount(%s, %s) failed with %v", mappingPath, source, err)
136-
}
128+
if err = incementRemotePathReferencesCount(mappingPath, source); err != nil {
129+
klog.Warningf("incementMappingPathCount(%s, %s) failed with %v", mappingPath, source, err)
137130
}
138131

139132
return nil

0 commit comments

Comments
 (0)