fix(cron): run no_agent scripts in workdir without process-global chdir - #40964
fix(cron): run no_agent scripts in workdir without process-global chdir#40964xy200303 wants to merge 1 commit into
Conversation
|
Thanks for isolating the original module-global race. This patch cannot be applied to current Problems
Suggested changes
Automated hermes-sweeper review. |
The no_agent + workdir path in run_job applied the workdir via a process-global os.chdir() outside _terminal_cwd_lock. That had two problems: - _run_job_script hardcoded subprocess.run(cwd=<script dir>), so the chdir never reached the script — workdir silently had no effect for no_agent jobs despite the comment claiming it set the subprocess cwd. - A sequential-pool workdir job can overlap parallel-pool jobs, so the process-wide chdir bled the workdir into concurrently running workdir-less jobs for the whole script run — the same bug class as the TERMINAL_CWD override that _terminal_cwd_lock guards. Pass the workdir through to _run_job_script(cwd=...) instead, so the script subprocess gets the workdir as its cwd with zero process-global state. A workdir that vanished on disk now warns and falls back to the script directory, matching the agent path's behavior. Regression coverage in TestNoAgentWorkdir: workdir reaches the script subprocess, the process cwd is not mutated while a workdir job's script runs concurrently, missing workdir warns and falls back, and the no-workdir default is unchanged.
a95faab to
5975828
Compare
|
Thanks for the review — agreed that the previous revision targeted machinery that #43956 deliberately removed. I've re-scoped the PR against the current per-profile scheduler architecture instead of restoring any per-job profile contract. While auditing The revised patch passes the workdir through to |
Summary
profilesupport was deliberately removed in revert(cron): remove per-job profile support (#28124) #43956, so the original profile-home race (cron scheduler: profile-job context bleeds into concurrent non-profile job (script not found) #39886) no longer exists onmain—_hermes_homeis read-only now and cron runs per-profile inside a profile-scoped gateway.no_agent + workdirpath inrun_jobapplied the workdir via a process-globalos.chdir()outside_terminal_cwd_lock. A sequential-pool workdir job can overlap parallel-pool jobs, so the chdir bled the workdir into concurrently running workdir-less jobs for the whole script run._run_job_scripthardcodedsubprocess.run(cwd=<script dir>), so the chdir never even reached the script —workdirsilently had no effect forno_agentjobs despite the comment claiming it set the subprocess cwd.Fix
_run_job_scriptgains acwdparameter, passed tosubprocess.run(); when omitted the script runs in its own directory, preserving prior behavior for the agent pre-run / wake-gate call sites.run_job's no_agent path passes the job'sworkdiras the script subprocess cwd and dropsos.chdirentirely — zero process-global state.Tests
TestNoAgentWorkdirintests/cron/test_cron_workdir.py(4 tests):tests/cron/suite passes.