Repository navigation
[Core] Don't consider file locks when checking working dir cleanup - #68526
Conversation
Signed-off-by: davik <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function list_package_files in test_working_dir_cleanup to filter out .lock files when listing package files, addressing issues caused by filelock>=4 keeping lock files on disk. The review feedback correctly identifies a Python 3.8 compatibility issue with the list[str] type hint and suggests removing the return type annotation to prevent a TypeError.
| await plugin.create(HTTPS_PACKAGE_URI, {}, RuntimeEnvContext()) | ||
|
|
||
| files = os.listdir(f"{tmpdir}/working_dir_files") | ||
| def list_package_files() -> list[str]: |
There was a problem hiding this comment.
Using list[str] as a type hint requires Python 3.9+. If this test file is executed on Python 3.8, it will raise a TypeError: 'type' object is not subscriptable because from __future__ import annotations is not imported at the top of the file. Since this is a local helper function inside a test, we can safely remove the return type annotation to ensure compatibility across all supported Python versions.
| def list_package_files() -> list[str]: | |
| def list_package_files(): |
Description
test_working_dir_cleanupintest_runtime_env_working_dirhas recently been flaky. Upon investigation, we see that the failure began occurring after we've upgraded the filelock version in #68360. The working dir cleanup test works by checking the ctime of files to ensure that a previous file has been cleaned up. However, the upgrade from filelock3.29.0to4.2.12meant that where3.29used to cleanup the file lock file, the4.2.12change no longer does this to ensure stronger mutual exclusion guarantees. tox-dev/filelock#574This PR deflakes the
test_working_dir_cleanupby ignoring the filelock files since those are now persisted for stronger safety. Though the files themselves have 0 bytes, they do incur an inode per unique URI that the user needs for the runtime env. Because we do not expect a large number of unique URI throughout the lifetime of a job, we have decided to keep consistent with filelock's decision for stronger mutual exclusion guarantees.Related issues
Additional information
Postmerge run post fix: https://buildkite.com/ray-project/postmerge/builds/21232