Skip to content

Commit

Permalink
SMBMount: return error when getRootMappingPath fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliy-leschenko committed Aug 8, 2022
1 parent cb1fdba commit a531ba4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pkg/mounter/safe_mounter_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,11 @@ func (mounter *csiProxyMounter) SMBMount(source, target, fsType string, mountOpt
source = strings.TrimSuffix(source, "\\")
}

// Try to lock `mappingPath`. We avoid throwing any exception to backward compatibility.
unlock := func() {}
mappingPath, err := getRootMappingPath(source)
if err != nil {
klog.Warningf("getRootMappingPath(%s) failed with %v", source, err)
} else {
unlock = lock(mappingPath)
return fmt.Errorf("getRootMappingPath(%s) failed with %v", source, err)
}
unlock := lock(mappingPath)
defer unlock()

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

if mappingPath != "" {
// When mount successful tries to increment mapping reference count.
err = incementRemotePathReferencesCount(mappingPath, source)
if err != nil {
klog.Warningf("incementMappingPathCount(%s, %s) failed with %v", mappingPath, source, err)
}
if err = incementRemotePathReferencesCount(mappingPath, source); err != nil {
klog.Warningf("incementMappingPathCount(%s, %s) failed with %v", mappingPath, source, err)
}

return nil
Expand Down

0 comments on commit a531ba4

Please sign in to comment.