-
Notifications
You must be signed in to change notification settings - Fork 7k
[FIX] raise error if job does not terminate in tail_job_logs() #57037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
efa79d6
aea0717
c011722
d4b73e6
83ad810
21e1ecc
0dcb9aa
f1bfdd5
e62dac9
fc81dee
d1c0c29
899c05d
a21145f
a2e76fd
2df9d50
b51feb2
8035a6b
681a536
5ed2be4
1406cd3
c1e93cd
905d742
238e0fb
5186f4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,8 +482,9 @@ async def tail_job_logs(self, job_id: str) -> AsyncIterator[str]: | |
| The iterator. | ||
|
|
||
| Raises: | ||
| RuntimeError: If the job does not exist or if the request to the | ||
| job server fails. | ||
| RuntimeError: If the job does not exist, if the request to the | ||
| job server fails, or if the connection closes unexpectedly | ||
| before the job reaches a terminal state. | ||
| """ | ||
| async with aiohttp.ClientSession( | ||
| cookies=self._cookies, headers=self._headers | ||
|
|
@@ -498,6 +499,17 @@ async def tail_job_logs(self, job_id: str) -> AsyncIterator[str]: | |
| if msg.type == aiohttp.WSMsgType.TEXT: | ||
| yield msg.data | ||
| elif msg.type == aiohttp.WSMsgType.CLOSED: | ||
| logger.debug( | ||
| f"WebSocket closed for job {job_id} with close code {ws.close_code}" | ||
| ) | ||
| if ws.close_code == aiohttp.WSCloseCode.ABNORMAL_CLOSURE: | ||
| raise RuntimeError( | ||
| f"WebSocket connection closed unexpectedly with close code {ws.close_code}" | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: WebSocket Closure Triggers Unintended Job ErrorsThe |
||
| break | ||
| elif msg.type == aiohttp.WSMsgType.ERROR: | ||
| pass | ||
| # Old Ray versions may send ERROR on connection close | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when did this behavior change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I encounter the error in test |
||
| logger.debug( | ||
| f"WebSocket error for job {job_id}, treating as normal close. Err: {ws.exception()}" | ||
| ) | ||
| break | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it easy to write a test for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me have a try!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 899c05d