Skip to content

[Core] Don't consider file locks when checking working dir cleanup - #68526

Merged
rueian merged 1 commit into
ray-project:masterfrom
Kunchd:deflake-test_working_dir_cleanup
Nov 25, 2026
Merged

rueian merged 1 commit into
ray-project:masterfrom
Kunchd:deflake-test_working_dir_cleanup

Conversation

@Kunchd

@Kunchd Kunchd commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

test_working_dir_cleanup in test_runtime_env_working_dir has 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 filelock 3.29.0 to 4.2.12 meant that where 3.29 used to cleanup the file lock file, the 4.2.12 change no longer does this to ensure stronger mutual exclusion guarantees. tox-dev/filelock#574

This PR deflakes the test_working_dir_cleanup by 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

@Kunchd
Kunchd requested a review from a team as a code owner November 24, 2026 21:38

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
def list_package_files() -> list[str]:
def list_package_files():

@Kunchd Kunchd added the go add ONLY when ready to merge, run all tests label Nov 24, 2026

@MortalHappiness MortalHappiness left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Nov 25, 2026
@rueian
rueian merged commit e0d41f2 into ray-project:master Nov 25, 2026
7 checks passed
@Kunchd
Kunchd deleted the deflake-test_working_dir_cleanup branch November 25, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants