Skip directory entries in RecursiveCopyableDataset to fix IOException on empty source dirs#4181
Open
agam-99 wants to merge 2 commits intoapache:masterfrom
Open
Skip directory entries in RecursiveCopyableDataset to fix IOException on empty source dirs#4181agam-99 wants to merge 2 commits intoapache:masterfrom
agam-99 wants to merge 2 commits intoapache:masterfrom
Conversation
…avoid IOException on empty source dirs When source.path is an empty directory, FileListUtils.listFilesToCopyAtPath (includeEmptyDirectories=true) returns the directory itself as the sole FileStatus entry. The subsequent call to resolveReplicatedOwnerAndPermissionsRecursively passes file.getPath().getParent() as fromPath — which is *above* replacedPrefix — inverting the ancestry check and throwing an IOException. Skip FileStatus entries where isDirectory=true; empty source directories produce no copy work units by design. Log a warning so operators can diagnose misconfigured source paths.
… in RecursiveCopyableDataset When includeEmptyDirectories=true and the source root is empty, FileListUtils returns the root directory itself as a FileStatus entry. Calling .getParent() on it produces a path above replacedPrefix, breaking the ancestry check in resolveReplicatedOwnerAndPermissionsRecursively. Fix: guard with isAncestor(replacedPrefix, parentPath) — fall back to the file's own path only when parentPath is above the dataset root. This preserves correct ancestor permission replication for nested empty subdirs (where .getParent() is still within replacedPrefix) and ensures the empty root directory is replicated at the destination rather than skipped. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4181 +/- ##
============================================
+ Coverage 43.26% 43.30% +0.03%
- Complexity 2583 2587 +4
============================================
Files 516 516
Lines 22087 22101 +14
Branches 2505 2505
============================================
+ Hits 9557 9570 +13
- Misses 11566 11569 +3
+ Partials 964 962 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dear Gobblin maintainers,
Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
JIRA
Description
RecursiveCopyableDataset.getCopyableFilesImpliterates overfilesInSourceentries and callsCopyableFile.resolveReplicatedOwnerAndPermissionsRecursively(fs, file.getPath().getParent(), replacedPrefix, ...)for each. This method walks from
file.getPath().getParent()up toreplacedPrefixcollectingdirectory permissions to replicate at the destination. It requires
replacedPrefixto be anancestor of
file.getPath().getParent().When
source.pathpoints to an empty directory,FileListUtils.listFilesToCopyAtPath(with
includeEmptyDirectories=true) returns the directory itself as the soleFileStatusentry.For this entry
file.getPath() == replacedPrefix, sofile.getPath().getParent()is one levelabove
replacedPrefix. This inverts the ancestry check and throws:IOException: toPath /jobs/.../edp_lts_opsreview must be an ancestor of fromPath hdfs://cluster/.../u_ltscso.db
Fix: Guard the
fromPathargument passed toresolveReplicatedOwnerAndPermissionsRecursivelywith an
isAncestorcheck:When parentPath is within replacedPrefix (normal files, nested empty subdirs) it is used
unchanged — no behavior change. When parentPath is above replacedPrefix (empty root dir),
file.getPath() is used instead, which equals replacedPrefix, causing the walk to produce an
empty ancestors list. The empty directory is still replicated at the destination.
Tests
Added
testEmptySourceDirectoryProducesCopyEntityForDirectorytoRecursiveCopyableDatasetTest:filesInSourcecontains only theempty-directory
FileStatusentry (as returned byFileListUtilswhenincludeEmptyDirectories=true)getCopyableFilesproduces one copy entity mapping the empty directory to thetarget path, rather than throwing
IOExceptionCommits
if they address the same issue. In addition, my commits follow the guidelines from
"How to write a good git commit message":