Repository navigation
fix(cron): surface external-worker dispatch failures through the incident path - #123432
Closed
liuhao1024 wants to merge 1 commit into
Closed
liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…dent path A failed restart-safe handoff in run_one_job() recorded the failure on the job and in the executions ledger, then returned before any incident or delivery path ran: no cron_incidents row, no failure-lane notice. Route the dispatch-failure branch through _deliver_crash_failure() so it opens the same job+signature incident and delivers the same failure notice as any other job failure, with the existing alerted-cooldown withholding repeats. A notice-path exception no longer loses the bookkeeping: mark_job_run and finish_execution still run with a "failed" delivery outcome (NousResearch#123401).
|
🤖 Hermes Agent automated review: PR reviewed. Diff analyzed (94 lines changed). Check CI status and manual review recommended. |
|
Thanks @liuhao1024. This lands through #124013 with your commit and authorship kept. Two follow-ups were added on top: |
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.
What does this PR do?
When the restart-safe external-worker handoff fails,
run_one_job()recorded the failure on the job and in the executions ledger, then returnedTruebefore any operator-facing path ran: nocron_incidentsrow was opened and no failure notice left through the job's failure lane. A dispatch-level outage was therefore completely silent whileexecutions.dbaccumulatedstatus='failed'rows — exactly the situation reported in #123401, where a 9.5-hour outage (106 failed executions, including three jobs whose entire purpose is alerting) produced zero notifications.This routes the dispatch-failure branch through
_deliver_crash_failure(), the same machinery already used whenrun_jobraises: it upserts the job+signature incident, delivers the failure summary through the job's failure lane, and marks the incidentalertedonce the notice is out. The existing alerted-cooldown semantics then apply, so repeated identical dispatch failures alert once instead of pinging per run. A notice-path exception cannot lose the bookkeeping:mark_job_run/finish_executionstill run with a"failed"delivery outcome.Related Issue
Fixes #123401
Type of Change
Changes Made
cron/scheduler.py— inrun_one_job()'shandoff_errorbranch, call_deliver_crash_failure(job, error, adapters, loop)(wrapped defensively) beforemark_job_run, and threaddelivery_error/delivery_outcomeintomark_job_run/finish_executionso the ledger records the notice outcome like the normal crash path does.tests/cron/test_restart_safe_worker.py— addtest_dispatch_failure_opens_incident_and_delivers_failure_notice: a failed handoff must open exactly one incident row (statealerted, original dispatch error), deliver one failure-lane notice, and finish the executionfailed/delivered; a repeat of the same failure dedups to the same incident and is withheld (suppressed_acked, no second ping).How to Test
pytest tests/cron/test_restart_safe_worker.py -q— all pass, including the new regression test.cron/scheduler.pyhunk stashed, the new test fails withassert 0 == 1onincidents.list_incidents()— the silent-outage shape from the issue — and passes again with the fix.pytest tests/cron/test_oneshot_dispatch_failure_run_claim.py tests/cron/test_execution_ledger.py tests/cron/test_cron_failure_deliver.py tests/cron/test_cron_incidents_resolve.py tests/tools/test_cronjob_tools.py tests/tools/test_cronjob_run_background.py tests/tools/test_cronjob_run_delivery_notice.py tests/tools/test_cronjob_run_immediate.py tests/cron/test_scheduler_provider.py -q— all pass (Observed result: 223 passed across the dispatch/ledger/incident/delivery surface).ruff check cron/scheduler.py tests/cron/test_restart_safe_worker.py— clean.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
New regression test output (green):
Red (scheduler hunk stashed) — the pre-fix silent shape from the issue: