shuan1026 opened a new pull request, #11889: URL: https://github.com/apache/ozone/pull/11889
## What changes were proposed in this pull request? `ofs` / `o3fs` encode a rename to the bucket root as `renameKey(from, "")`. That empty destination is a supported success path (`testKeyRenameToBucketLevel`, `OzoneRpcClientTests#testRenameKey`). For FSO buckets the clients do not check the destination themselves; OM does. When `toKeyName` is empty, `getOMKeyInfoIfExists` returns null, so `prepareRename` takes the destination-absent branch and skips the collision checks used for every other destination. `renameKey` then writes the source leaf under `/volumeId/bucketId/bucketId/<leaf>` and can replace a root directory (orphaning its subtree) or a root file. This patch adds the missing lookup in that branch, before `getKeyParentDir`. If the bucket root already has a file or directory with the source leaf name, OM throws `KEY_ALREADY_EXISTS`, and `FileSystem.rename` on `ofs` / `o3fs` returns `false`, as it already does when an explicit destination directory has a child with that name. The check is skipped when the source is already at the root, so `renameKey(rootKey, "")` still succeeds. The empty destination is not rewritten to the leaf name before the existing destination lookup. Doing that would turn a collision with a root directory into a rename *into* that directory (case-4) instead of a failure. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-16762 ## How was this patch tested? - `TestOMKeyRenameRequestWithFSO`: `testRenameToBucketRootKeepsFileName`, `testRenameBucketRootFileToBucketRoot`, `testRenameToBucketRootWithExistingFile`, `testRenameToBucketRootWithExistingDirectory`, `testRenameDirectoryToBucketRootOntoItsParent`. The three collision tests fail with `expected: <KEY_ALREADY_EXISTS> but was: <OK>` before the production change and pass after it. - Existing `TestOFSWithFSO` rename tests (including `testKeyRenameToBucketLevel`) and `TestOzoneRpcClient#testRenameKey` still pass. - CI: https://github.com/shuan1026/ozone/actions/runs/41318052721 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
