Commit 9178dbe
Fix orphaned worker pods: log deletion errors, eliminate TOCTOU race (#385)
Two bugs caused worker pods to remain running after the janitor
marked them retired in the DB:
1. retireWorkerPod silently discarded pod deletion errors with _.
If the K8s API delete failed (timeout, network blip), the pod
stayed running with no indication in logs. Now logs the error.
2. retireLocalWorker had a TOCTOU race: it checked p.workers[id]
then called retireWorkerWithReason which checked again. If the
worker was removed between the two checks, retireLocalWorker
returned true (thinking it handled it) but the pod was never
deleted, and the fallback retireRuntimeWorker was never called.
Fix: retireWorkerWithReason now returns bool. retireLocalWorker
returns the result directly — no separate existence check.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent aab475e commit 9178dbe
2 files changed
Lines changed: 15 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
818 | 820 | | |
819 | 821 | | |
820 | 822 | | |
821 | 823 | | |
822 | | - | |
| 824 | + | |
823 | 825 | | |
824 | 826 | | |
825 | 827 | | |
| |||
828 | 830 | | |
829 | 831 | | |
830 | 832 | | |
| 833 | + | |
831 | 834 | | |
832 | 835 | | |
833 | 836 | | |
| |||
1655 | 1658 | | |
1656 | 1659 | | |
1657 | 1660 | | |
1658 | | - | |
| 1661 | + | |
| 1662 | + | |
1659 | 1663 | | |
1660 | 1664 | | |
1661 | 1665 | | |
1662 | | - | |
1663 | 1666 | | |
1664 | 1667 | | |
1665 | | - | |
| 1668 | + | |
1666 | 1669 | | |
1667 | | - | |
1668 | | - | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
1669 | 1676 | | |
1670 | 1677 | | |
1671 | 1678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 226 | + | |
234 | 227 | | |
235 | 228 | | |
236 | 229 | | |
| |||
0 commit comments