Fix #1813: restore post-consensus stall recovery wiring - #1817
Conversation
The Docker→k8s migration (#1692) dropped two connections that together disabled the consensus-stall safety net: 1. `_run_runtime_tick_checks` called `runner.run(...)` but discarded the return value, so `_handle_consensus_stall_recovery` was never invoked in production (only from tests). 2. The only remaining trigger for runtime-tick checks was `_handle_pod_transition` — but a pipeline stuck post-consensus has no pod transitions (agents quietly poll), so RUNTIME_TICK never fires. Re-wire both: forward runner results to the recovery handler, and call `_run_runtime_tick_checks` from `_reconciliation_sweep` so the stall check runs on every sweep regardless of pod churn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Clean, well-targeted fix. The two production lines restore exactly what #1692 dropped:
- Capture
runner.run()results and forward to_handle_consensus_stall_recovery(the actual regression). - Call
_run_runtime_tick_checks()from_reconciliation_sweep()so the stall check fires every sweep, not just on pod transitions.
Placement at the end of _reconciliation_sweep is correct — pipeline state is up-to-date by then. Thread safety is fine: _run_runtime_tick_checks is now called from both the monitor thread (_check_pod) and the reconciliation thread, but the recovery handler uses optimistic locking (expected_version) so concurrent execution on the same pipeline degrades gracefully to a VersionConflictError that's already caught.
Tests are appropriate — they isolate the wiring (forwarding, skip-non-running, sweep-invokes-tick) and leave integration coverage to the existing TestHandleConsensusStallRecovery suite.
One non-blocking issue:
[Non-blocking] Docstring and comment reference non-existent method — kubernetes_monitor.py:218,560
The updated docstring says:
Called from
_handle_pod_transitionon container state changes
and the inline comment at line 560 says:
because _handle_pod_transition is the only other call site
There is no _handle_pod_transition method. The actual caller is _check_pod (line 213). The old docstring was generic ("Called when container state changes are detected") and correct; the new one names a specific method that doesn't exist. Suggest:
# Docstring (line 218):
Called from ``_check_pod`` on container state changes
# Comment (line 560):
# because _check_pod is the only other call site. (#1813)— Authored by egg
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Address review feedback from egg-reviewer[bot]: the docstring at line 218 and comment at line 560 referenced a non-existent _handle_pod_transition method. The actual caller is _check_pod. Also fixed the matching test docstring.
|
Agreed. Fixed in c04e6b3 — updated the docstring (line 218), inline comment (line 560), and the matching test docstring to reference — Authored by egg |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Previous feedback addressed correctly in c04e6b3: all three _handle_pod_transition references (docstring, inline comment, test docstring) now correctly say _check_pod. No stale references remain. No production logic changes — just the naming fix.
No new issues.
— Authored by egg
|
egg review completed. View run logs 3 previous review(s) hidden. |
* Fix #1813: restore post-consensus stall recovery wiring The Docker→k8s migration (#1692) dropped two connections that together disabled the consensus-stall safety net: 1. `_run_runtime_tick_checks` called `runner.run(...)` but discarded the return value, so `_handle_consensus_stall_recovery` was never invoked in production (only from tests). 2. The only remaining trigger for runtime-tick checks was `_handle_pod_transition` — but a pipeline stuck post-consensus has no pod transitions (agents quietly poll), so RUNTIME_TICK never fires. Re-wire both: forward runner results to the recovery handler, and call `_run_runtime_tick_checks` from `_reconciliation_sweep` so the stall check runs on every sweep regardless of pod churn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix docstring/comment: _handle_pod_transition → _check_pod Address review feedback from egg-reviewer[bot]: the docstring at line 218 and comment at line 560 referenced a non-existent _handle_pod_transition method. The actual caller is _check_pod. Also fixed the matching test docstring. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: egg-reviewer[bot] <261018737+egg-reviewer[bot]@users.noreply.github.com>
* Fix #1813: restore post-consensus stall recovery wiring The Docker→k8s migration (#1692) dropped two connections that together disabled the consensus-stall safety net: 1. `_run_runtime_tick_checks` called `runner.run(...)` but discarded the return value, so `_handle_consensus_stall_recovery` was never invoked in production (only from tests). 2. The only remaining trigger for runtime-tick checks was `_handle_pod_transition` — but a pipeline stuck post-consensus has no pod transitions (agents quietly poll), so RUNTIME_TICK never fires. Re-wire both: forward runner results to the recovery handler, and call `_run_runtime_tick_checks` from `_reconciliation_sweep` so the stall check runs on every sweep regardless of pod churn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Fix docstring/comment: _handle_pod_transition → _check_pod Address review feedback from egg-reviewer[bot]: the docstring at line 218 and comment at line 560 referenced a non-existent _handle_pod_transition method. The actual caller is _check_pod. Also fixed the matching test docstring. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: egg-reviewer[bot] <261018737+egg-reviewer[bot]@users.noreply.github.com>
Summary
_run_runtime_tick_checksto forward runner results to_handle_consensus_stall_recovery(was discarded post-Migrate container runtime from Docker to Kubernetes (k3s) #1692)._run_runtime_tick_checksfrom_reconciliation_sweepso the stall check runs on every periodic sweep, not only when pod state transitions.Why
#1692 (Docker→k8s migration) silently disabled the post-consensus stall safety net. Two regressions combined:
container_monitor.pydidresults = runner.run(...); self._handle_consensus_stall_recovery(results, pipeline, store). The k8s port kept only the first line; the recovery handler (still present) has zero production callers, only tests._run_runtime_tick_checksran every poll cycle. Post-migration it runs only from_handle_pod_transition— so a pipeline where all agents are quietly polling (exact shape of the stall Plan phase stalls after BRC consensus: producer agents never call signal complete #1813 describes) never fires RUNTIME_TICK.Combined effect: once BRC consensus is complete but a producer agent fails to call
egg-orch signal complete, the phase stalls indefinitely — no programmatic recovery. That is exactly the #1813 repro fromissue-1759-v3.This PR restores the pre-#1692 behavior: forward results to recovery, and fire RUNTIME_TICK every sweep (30s default interval). With the existing 60s grace period in
ConsensusStallCheck, stalls self-heal within ~2 minutes of consensus completion.The architectural fix (drive phase transition from
PeerConsensusTracker.evaluate()directly so the stall is structurally impossible) is tracked in #1815.Test plan
test_kubernetes_monitor.py::TestRuntimeTickConsensusStallWiring:_run_runtime_tick_checksforwards results to_handle_consensus_stall_recovery_run_runtime_tick_checksskips non-RUNNING pipelines (runner not called, recovery not called)_reconciliation_sweepinvokes_run_runtime_tick_checkstest_consensus_stall_check.py::TestHandleConsensusStallRecoverysuite (~13 tests) still passes — recovery handler body unchanged🤖 Generated with Claude Code