Repository navigation
Conversation
update_hasher_for_source sorted each directory's files but not its subdirectories, so os.walk visited them in filesystem readdir order. Identical source trees therefore produced different image tags on machines whose filesystems list directories in different orders, forcing rebuilds and re-pushes of images that already exist. Sort dirnames in place so the walk order is deterministic everywhere. Fixes flyteorg/flyte#8455
Author
|
Closing as a duplicate of #1868, which was opened earlier and fixes the same issue (flyteorg/flyte#8455). |
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.
Problem
update_hasher_for_sourcesorted each directory's files but never sorteddirnames, soos.walkvisited subdirectories in filesystem readdir order. Identical source trees therefore produced different image tags on machines whose filesystems list directories in different orders, so images that already existed in the registry were rebuilt and pushed again.Reported in flyteorg/flyte#8455.
Fix
Sort
dirnamesin place inside theos.walkloop (next to the existingfiles.sort()). Sorting in place is what makesos.walkrecurse in deterministic order.Testing
tests/flyte/_utils/test_file_handling.py: hashes the same tree through two deterministicos.walkstand-ins that visit entries in ascending and descending name order, and asserts the digests match. It fails on the currentmainand passes with this change, independent of the host filesystem's readdir order.uv run python -m pytest -k "not integration and not sandbox and not gpu and not external" tests/flyte/_utils tests/flyte/test_image.py tests/flyte/imagebuild: 241 passed, 1 skippeduv run python -m pytest -k "not integration and not sandbox" tests/flyte/code_bundle: 105 passedruff checkandruff format --check: cleanFixes flyteorg/flyte#8455