fix(cron): clean up job output dir in remove_job#21882
Merged
Merged
Conversation
remove_job() deletes the job from cron/jobs.json but leaves the per-job
output directory at ~/.hermes/cron/output/{job_id}/ behind. Over time
this accumulates orphaned dirs that never get reclaimed.
Adopted from #13510 by @hekaru-agent; the honcho RLock half of that PR
was already salvaged in commit dad0217 so this lands the remaining
cron cleanup hunk on its own.
Contributor
🔎 Lint report:
|
| save_jobs(jobs) | ||
| # Clean up output directory to prevent orphaned dirs accumulating | ||
| job_output_dir = OUTPUT_DIR / job_id | ||
| if job_output_dir.exists(): |
| # Clean up output directory to prevent orphaned dirs accumulating | ||
| job_output_dir = OUTPUT_DIR / job_id | ||
| if job_output_dir.exists(): | ||
| shutil.rmtree(job_output_dir) |
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.
Summary
remove_job()now removes the per-job output directory at~/.hermes/cron/output/{job_id}/so deleted jobs don't leave orphaned dirs accumulating forever.Changes
cron/jobs.py: aftersave_jobs(jobs)inremove_job,shutil.rmtreethe job's output dir if it exists.Context
Salvaged from #13510 by @hekaru-agent. The honcho RLock half of that PR was already merged as commit dad0217; this lands the remaining cron cleanup hunk on its own with authorship preserved.
Validation
E2E: seeded a job, wrote output, called
remove_job— job + output dir both gone. Nonexistent id still returns False. Job that never produced output removes cleanly without crashing.Closes #13510.