Repository navigation
storage: compare visited paths as folders, so x2 is staged after x (fslink, swift, s3) - #182
Open
rudolphpienaar wants to merge 2 commits into
Open
rudolphpienaar wants to merge 2 commits into
rudolphpienaar wants to merge 2 commits into
Conversation
…er x FSLinkStorage._find_all_file_paths skipped any storage path that started, as a string, with an already-visited path. After following a ChRIS link to home/u/uploads/x, a link to home/u/uploads/x2 was treated as visited and its files were never fetched into the job incoming dir. BaseStorage._process_chrislink_files made the same string comparison against the set of already-copied link sources. Add BaseStorage.is_path_under, which treats a path as under a root only when it equals the root or starts with the root plus '/', and use it in both places. A real descendant (x/sub after x) is still skipped as before. Fixes #180
SwiftStorage and S3Storage._find_all_storage_object_paths made the same string-prefix visited check as FSLinkStorage, so after following a ChRIS link to home/u/uploads/x a link to home/u/uploads/x2 was not visited. Use BaseStorage.is_path_under there too. Both backends list objects by name prefix, so listing x already returned the objects under x2 and the staged files were complete. The check now visits x2 itself instead of relying on that over-broad listing. The new tests use an in-memory manager with the same prefix listing and assert which prefixes are listed.
x2 is staged after xx2 is staged after x (fslink, swift, s3)
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.
Bug
FSLinkStorage._find_all_file_pathsskips a storage path whenany(storage_path.startswith(p) for p in visited_paths). The comparison is on text, so once a ChRIS link tohome/<user>/uploads/xhas been followed, a link tohome/<user>/uploads/x2counts as already visited and its files are never fetched.BaseStorage._process_chrislink_filesmakes the same text comparison (link_file_path.startswith(p) for p in self._already_copied_src_set), and so doSwiftStorageandS3Storagein_find_all_storage_object_paths.In 5.2.x/5.3.x the fslink expansion then fails with
No such file or directory: …/incoming/home/<user>/uploads/x2and CUBE cancels the job. On current master the failed copy is caught (except FileNotFoundError: pass), so the job runs without thex2files instead of failing.Swift and S3 list objects by name prefix, so listing
xalready returns the objects underx2and their staged files were complete. The check was still wrong there:x2was never visited and only arrived through that broader listing.Found on a CUBE 6.11 + pfcon 5.2.4 deployment (in-network,
STORAGE_ENV=fslink).Fix
Add
BaseStorage.is_path_under(path, root): true whenpathequalsrootor starts withroot + '/'(trailing/onrootignored). All four checks use it:pfcon/storage/base_storage.py:_process_chrislink_filespfcon/storage/fslink_storage.py:_find_all_file_pathspfcon/storage/swift_storage.py:_find_all_storage_object_pathspfcon/storage/s3_storage.py:_find_all_storage_object_pathsA real descendant (
x/subafterx) is still skipped as before. Nothing else changes. The otherstartswithcalls inpfcon/storage/are the job-output ancestor checks, which already compare with a trailing/.Test
Each backend gets a unit test class next to its existing tests. The tests need no Docker, Swift or S3. Each one builds an input folder holding two
.chrislinkfiles, likepl-dircopyoutput, runsstore_data(which callsprocess_chrislink_files) into a temporary job incoming dir, and checks the staged tree andnfiles.tests/test_resources_fslink.py,TestFSLinkStorageStoreDataLinkedFolders, on a temporary storeBase:xandx2: both folders staged. Fails before the fix (nfiles1,x2missing).x1andx2(control): both staged, before and after.xandx/sub(real nesting):xwithsub/, plusx/subon its own, before and after.is_path_underon its own: equal, trailing slash, descendant, siblingx2, ancestor.os.walkis wrapped to return sorted names, sox.chrislinkis always followed beforex2.chrislink. Without that, directory order depends on the filesystem and the bug may not show.tests/test_resources_swift.py,TestSwiftStorageStoreDataLinkedFolders, andtests/test_resources_s3.py,TestS3StorageStoreDataLinkedFolders, with an in-memory manager whoselslists by name prefix like the real backends and records each prefix it is asked for:xandx2:x2is listed, and both folders are staged. Fails before the fix (x2never listed).x1andx2(control): both listed and staged, before and after.xandx/sub:x/subis not listed again afterx, before and after.Run locally without Docker:
Fixes #180
Part of #181