[ 
https://issues.apache.org/jira/browse/HADOOP-20062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18138459#comment-18138459
 ] 

ASF GitHub Bot commented on HADOOP-20062:
-----------------------------------------

LuciferYang opened a new pull request, #8926:
URL: https://github.com/apache/hadoop/pull/8926

   ### Description of PR
   
   JIRA: https://issues.apache.org/jira/browse/HADOOP-20062
   
   These three methods run the path through `fixRelativePart()` and an 
`FSLinkResolver`, but `next(fs, p)` calls the file system with the caller's 
original path instead of `p`. A relative path is not resolved against the 
working directory: on HDFS, `fc.setStoragePolicy(new Path("dir"), "COLD")` 
fails with `relative paths not allowed`, while `fc.getStoragePolicy(new 
Path("dir"))` works. When the file system throws `UnresolvedLinkException`, the 
resolver retries with the link path again and ends with `Possible cyclic loop`.
   
   Every other resolver in `FileContext` passes `p`, and this patch does the 
same. Absolute paths without symlinks behave as before.
   
   ### How was this patch tested?
   
   Added two cases to `TestFileContext` with a mocked `AbstractFileSystem`:
   - `testStoragePolicyOpsQualifyRelativePath`: the three methods called with a 
relative path reach the file system with the path under the working directory.
   - `testStoragePolicyOpsFollowSymlink`: when the file system throws 
`UnresolvedLinkException` for a link, the three methods are applied to the link 
target.
   
   Without the fix the first fails on `verify` and the second with `Possible 
cyclic loop`.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: Have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   - [x] The PR includes the phrase "Contains content generated by Claude Opus".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Opus.
   




> FileContext#setStoragePolicy, #unsetStoragePolicy and #satisfyStoragePolicy 
> pass the unresolved path to the file system
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-20062
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20062
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>            Reporter: Yang Jie
>            Priority: Minor
>
> These three methods qualify the path with fixRelativePart() and run it 
> through an FSLinkResolver, but inside {{next(fs, p)}} they call the file 
> system with the caller's original path instead of {{p}}. As a result:
> * A relative path is not resolved against the working directory. On HDFS, 
> {{fc.setStoragePolicy(new Path("dir"), "COLD")}} fails with 
> "InvalidPathException: relative paths not allowed", while 
> {{fc.getStoragePolicy(new Path("dir"))}} on the same FileContext works.
> * When the file system throws UnresolvedLinkException, the resolver retries 
> with the link path again, so the call never reaches the link target and ends 
> with "Possible cyclic loop while following symbolic link".
> Every other FSLinkResolver in FileContext passes {{p}}, and the fix does the 
> same. Nothing changes for an absolute path without symlinks. HDFS-17843 is a 
> similar issue in DistributedFileSystem.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to