feat(scheduler): DB-driven SandboxLogArchiveTask, drop sentinel file design #1025
Open
jinbai340997 wants to merge 4 commits into
Open
feat(scheduler): DB-driven SandboxLogArchiveTask, drop sentinel file design #1025jinbai340997 wants to merge 4 commits into
jinbai340997 wants to merge 4 commits into
Conversation
…(fix cross-loop asyncpg pool)
…g if main loop dies)
f370ff3 to
4ab29e2
Compare
4ab29e2 to
30a4724
Compare
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
New files
rock/admin/scheduler/tasks/sandbox_log_archive_task.py— task implementation + module-level providers +_run_on_main_loopcross-loop dispatch
tests/unit/admin/scheduler/test_sandbox_log_archive_task.py— 18 unit tests covering classification (orphan / alive / too_young/ archived), credential-via-env, OSS key format, error isolation, cross-loop dispatch behavior
Modified files
rock/admin/main.py— wiresandbox_table/rock_config/main_loopproviders from lifespanrock/admin/scheduler/tasks/__init__.py— register new taskCross-loop dispatch contract
Safety cap
_CROSS_LOOP_DISPATCH_TIMEOUT = 60.0: if main loop is gone (admin was SIGKILLed before SchedulerThread stopped), thechild loop would otherwise hang forever. 60s is generous for any sandbox_table query; raises
TimeoutErrorif exceeded.Worker discovery hardening
_discover_candidatesusesfind -maxdepth 1 -mindepth 1 -type dto restrict to directories only. Earlierls -1returneddaemon-written files (
docuum.log,rocklet.log,rock_worker.log,access.log,command.log,rsync_logs_to_host.log,worker_metrics_monitor.log,image_pull.log) alongside real sandbox subdirs, each triggering a useless DB lookup and spurious"orphan log dir" warning.
Test plan
uv run pytest tests/unit/admin/scheduler/test_sandbox_log_archive_task.py -v— 18/18 PASSrun_actioninvocation:scanned=21–33, failed=0, zeroFuture attached to a different looperrors, classification counts match DB state
ossutil cp /tmp/test.txt oss://chatos-rock/...succeeded)oss://chatos-rock/rock-archives/sandbox-logs/<sandbox_id>.tar.gzappears after firstsandbox ages past
keep_days_before_archive=3(validates admin → worker env-cred injection path end-to-end)fixes [Feature] DB-driven SandboxLogArchiveTask (replaces sentinel-file design) #1024