Repository navigation
[core] Deflake test_stop_job_timeout by stopping the job only after its SIGTERM handler is installed - #63726
Merged
edoakes merged 2 commits intoMay 29, 2026
Conversation
…GTERM handler is installed Signed-off-by: Yicheng Lu <[email protected]>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors test_stop_job_timeout in test_job_manager.py to use file-based indicators (ready_file and handled_file via tmp_path) instead of checking stdout logs to verify that the job is ready and that the SIGTERM signal was handled. A review comment suggests using .as_posix() instead of str() on the file paths to prevent backslash escaping issues on Windows platforms.
Signed-off-by: Yicheng Lu <[email protected]>
Collaborator
Omg, great find! I'm impressed |
edoakes
approved these changes
May 29, 2026
edoakes
enabled auto-merge (squash)
May 29, 2026 18:19
rueian
pushed a commit
to rueian/ray
that referenced
this pull request
Jun 4, 2026
… its SIGTERM handler is installed (ray-project#63726) ## Description `test_stop_job_timeout` basically wants to do the following: - The driver installs a SIGTERM handler and, once installed, prints log A. - We grep for log A to make sure the SIGTERM handler is installed. - We then stop the job with SIGTERM, and the driver should not exit on it. - The handler also prints log B, which we check to confirm the handler actually ran. The problem is that grepping the log isn't reliable. Before launching the driver, the supervisor writes the entrypoint command into the log, and it includes the whole script source, including those two print A and B: https://github.com/ray-project/ray/blob/13e1bd138a209c0d1a5c50843c4a6d45b198eb6b/python/ray/dashboard/modules/job/job_supervisor.py#L179 So A and B are already in the log before the driver runs a single line. So we might end up sending SIGTERM before the driver installs the handler. So we use files instead: the driver creates one file after the handler is installed, and the handler creates another when it runs. This flaky test also reproduces on my local Mac, and I verified it is stable after the fix. --------- Signed-off-by: Yicheng Lu <[email protected]> Co-authored-by: Yicheng Lu <[email protected]>
limarkdcunha
pushed a commit
to limarkdcunha/ray
that referenced
this pull request
Jun 30, 2026
… its SIGTERM handler is installed (ray-project#63726) ## Description `test_stop_job_timeout` basically wants to do the following: - The driver installs a SIGTERM handler and, once installed, prints log A. - We grep for log A to make sure the SIGTERM handler is installed. - We then stop the job with SIGTERM, and the driver should not exit on it. - The handler also prints log B, which we check to confirm the handler actually ran. The problem is that grepping the log isn't reliable. Before launching the driver, the supervisor writes the entrypoint command into the log, and it includes the whole script source, including those two print A and B: https://github.com/ray-project/ray/blob/13e1bd138a209c0d1a5c50843c4a6d45b198eb6b/python/ray/dashboard/modules/job/job_supervisor.py#L179 So A and B are already in the log before the driver runs a single line. So we might end up sending SIGTERM before the driver installs the handler. So we use files instead: the driver creates one file after the handler is installed, and the handler creates another when it runs. This flaky test also reproduces on my local Mac, and I verified it is stable after the fix. --------- Signed-off-by: Yicheng Lu <[email protected]> Co-authored-by: Yicheng Lu <[email protected]>
400Ping
pushed a commit
to 400Ping/ray
that referenced
this pull request
Aug 18, 2026
… its SIGTERM handler is installed (ray-project#63726) ## Description `test_stop_job_timeout` basically wants to do the following: - The driver installs a SIGTERM handler and, once installed, prints log A. - We grep for log A to make sure the SIGTERM handler is installed. - We then stop the job with SIGTERM, and the driver should not exit on it. - The handler also prints log B, which we check to confirm the handler actually ran. The problem is that grepping the log isn't reliable. Before launching the driver, the supervisor writes the entrypoint command into the log, and it includes the whole script source, including those two print A and B: https://github.com/ray-project/ray/blob/13e1bd138a209c0d1a5c50843c4a6d45b198eb6b/python/ray/dashboard/modules/job/job_supervisor.py#L179 So A and B are already in the log before the driver runs a single line. So we might end up sending SIGTERM before the driver installs the handler. So we use files instead: the driver creates one file after the handler is installed, and the handler creates another when it runs. This flaky test also reproduces on my local Mac, and I verified it is stable after the fix. --------- Signed-off-by: Yicheng Lu <[email protected]> Co-authored-by: Yicheng Lu <[email protected]> Signed-off-by: 400Ping <[email protected]>
rueian
pushed a commit
that referenced
this pull request
Nov 10, 2026
## Description It is exactly the same issue as #63726. So, tldr, we had a test helper, its goal is: - Submit a job whose entrypoint is a shell script that writes its own pid + loops printing `Waiting...` - The helper makes sure when it returns, the shell is running. So that all tests can safely assume the job is running - The way it does is grepping the `Waiting...` The issue is exactly the same issue as #63726. Before launching the driver, the supervisor writes the entrypoint command into the job log, and the command itself contains `echo 'Waiting...'`: https://github.com/ray-project/ray/blob/fb7c757706aafd22025a2103268586cf138a143d/python/ray/dashboard/modules/job/job_supervisor.py#L186 So the grep matches before the shell has run a single line, the helper returns. This causes the test to be flaky. This PR fixes it. Signed-off-by: yicheng <[email protected]>
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.
Description
test_stop_job_timeoutbasically wants to do the following:The problem is that grepping the log isn't reliable. Before launching the driver, the supervisor writes the entrypoint command into the log, and it includes the whole script source, including those two print A and B:
ray/python/ray/dashboard/modules/job/job_supervisor.py
Line 179 in 13e1bd1
So A and B are already in the log before the driver runs a single line. So we might end up sending SIGTERM before the driver installs the handler.
So we use files instead: the driver creates one file after the handler is installed, and the handler creates another when it runs.
This flaky test also reproduces on my local Mac, and I verified it is stable after the fix.