optio
optio copied to clipboard
Active PR review pods are reaped after their active count is reset to zero
Description
The idle repo-pod cleanup deletes a pod while a PR review is still running. reconcileActiveTaskCounts() counts rows in tasks but ignores pr_review_runs, resetting the review pod's active_count from 1 to 0. The idle reaper later deletes the pod, and the review fails with:
The pod the agent ran in is gone. Inspect before relaunching.
The observed sequence on November 16, 2026, in UTC was:
14:05:04 Agent started; attaching
14:05:23 Reconciled pod activeCount: was=1, now=0
14:15:46 Review lastActivityAt updated
14:15:53 Cleaned up idle repo pod (StatefulSet scale-down)
14:16:29 Review failed: the pod is gone
The agent produced output seven seconds before its pod was removed.
Steps to Reproduce
- Start a PR review on a repo pod with no ordinary repo tasks using that pod.
- Let the review run beyond
OPTIO_REPO_POD_IDLE_MS(600000 ms by default). - Observe the cleanup sweep reset the pod's active count to zero and eventually delete the pod while the review remains
running.
Expected Behavior
Provisioning and running PR reviews keep their pod busy. Idle cleanup must preserve a pod that still hosts an active review, including when its stored counter is stale.
PR #677 protects review worktrees; this failure concerns the lifetime of the pod itself.
Environment
- Optio: v0.25.2; also present on main at
f5f5b86d. - OS: Linux agent containers, gVisor runtime.
- Node.js version: 26.12.1 in the API image.
- K8s cluster: Kubernetes 1.35.1, StatefulSet-managed repo pods.