Return unwrapped ErrNotExist when EvalSymlink returns PathError

By default filepath.EvalSymlink returns PathError. When a file is
not found, we should unwrap it and return ErrNotExist as this
is what this function expects.

Similar to the comment at:
https://github.com/kubernetes/kubernetes/pull/109217#discussion_r896272206
This commit is contained in:
Manu Gupta 2022-06-13 18:16:10 -07:00
parent 08ef11029f
commit 44bea35804

View File

@ -732,6 +732,9 @@ func (mounter *Mounter) IsMountPoint(file string) (bool, error) {
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts.
resolvedFile, err := filepath.EvalSymlinks(file)
if err != nil {
if errors.Is(isMntErr, fs.ErrNotExist) {
return false, fs.ErrNotExist
}
return false, err
}