[Jobs] Eagerly initialize JobManager on head startup - #65261
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces eager initialization of the JobManager on the head node within the JobAgent, along with a robust, budgeted retry mechanism for recovering running jobs. It also refactors the Ray connection initialization into a thread-safe helper (init_ray_connection) run within an executor. Feedback is provided to optimize the @init_ray_and_catch_exceptions decorator by checking if Ray is already initialized in the main thread, thereby avoiding the overhead of thread pool scheduling and lock acquisition on every HTTP request.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit d219241. Configure here.
Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: will <zzchun8@gmail.com>
d219241 to
a0d92d9
Compare

Summary
Eagerly initialize
JobManagerwhen the head Dashboard Agent starts sonon-terminal submission jobs are recovered without requiring a subsequent
Job API request.
Worker Dashboard Agents retain the existing lazy initialization behavior.
Problem
JobManager.__init__()schedules_recover_running_jobs(), butJobManageris lazily constructed by Job API handlers. After the head Dashboard Agent
restarts, existing
PENDINGorRUNNINGjobs may therefore remainunmonitored until another Job API request arrives.
This can leave stale jobs indefinitely in a non-terminal state when their
JobSupervisorno longer exists.Changes
JobManagerduring headJobAgent.run().ray.init()in an executor so Dashboard Agent startup does not blockthe asyncio event loop.
handlers.
Related issues
Fixes #65037
Additional information