resume_interrupted_scans (compliance-agent/src/lifecycle.rs) does not start a scan again once it has been interrupted more than once (MAX_RECENT_INTERRUPTIONS = 1) within 24 hours. The limit is meant to stop a loop where the scan itself stops the agent, through out-of-memory or a crash. But recover_orphaned_runs closes every open run as interrupted at startup, whatever ended the previous process. So a deploy restart (SIGTERM from Orca) counts the same as a crash. Two deploys in one day during a long scan are enough to drop it until the next scheduled run.
Seen on prod, 2026-11-05 (target 6ae9aa2160f5d8045fc570a7)
UTC
Event
06:00
Scheduled scan starts
07:54:55
Restart for the v0.4.10 rollout: run closed as interrupted, scan resumed (resumed=1)
08:19:30
Restart for orca-platform #149: resumed run closed as interrupted, then not resuming a scan interrupted again within a day; the next scheduled run tries with interruptions=2, resumed=0
13:01
Next scheduled scan starts (the 12:00 slot ran late)
Both interruptions were planned deploys, not crashes. The target went about 5 hours without a complete scan. Everything that waits for a complete scan waited too, such as closing CVE issues the scan no longer finds.
Expected
A scan stopped by a graceful shutdown is always resumed. Only interruptions the agent did not record itself (crash, OOM kill, a stop timeout that forces a kill) count toward MAX_RECENT_INTERRUPTIONS.
Proposal
On SIGTERM, before the grace period ends, close the agent's own running scan_runs with a distinct error code, for example RunErrorCode::Shutdown, plus completed_at. Startup resumes these, and they do not count in the window.
recover_orphaned_runs keeps closing whatever is still running as Interrupted, which now means the process ended without recording it. Only those runs count toward the limit.
Tests:
two graceful shutdowns in a row resume both times;
two unrecorded interruptions within 24 h still stop the resume;
one of each resumes.
The write on SIGTERM has to fit within shutdown::GRACE_PERIOD (8 s) and Docker's stop timeout. If it does not finish, the run stays running and is counted as unrecorded. The scan stops safely either way, but it may be resumed less often.
Related
#65: agent lifecycle, startup recovery and resume.
## What happens
`resume_interrupted_scans` (`compliance-agent/src/lifecycle.rs`) does not start a scan again once it has been interrupted more than once (`MAX_RECENT_INTERRUPTIONS = 1`) within 24 hours. The limit is meant to stop a loop where the scan itself stops the agent, through out-of-memory or a crash. But `recover_orphaned_runs` closes every open run as `interrupted` at startup, whatever ended the previous process. So a deploy restart (SIGTERM from Orca) counts the same as a crash. Two deploys in one day during a long scan are enough to drop it until the next scheduled run.
## Seen on prod, 2026-11-05 (target `6ae9aa2160f5d8045fc570a7`)
| UTC | Event |
| --- | --- |
| 06:00 | Scheduled scan starts |
| 07:54:55 | Restart for the v0.4.10 rollout: run closed as `interrupted`, scan resumed (`resumed=1`) |
| 08:19:30 | Restart for orca-platform #149: resumed run closed as `interrupted`, then `not resuming a scan interrupted again within a day; the next scheduled run tries` with `interruptions=2`, `resumed=0` |
| 13:01 | Next scheduled scan starts (the 12:00 slot ran late) |
Both interruptions were planned deploys, not crashes. The target went about 5 hours without a complete scan. Everything that waits for a complete scan waited too, such as closing CVE issues the scan no longer finds.
## Expected
A scan stopped by a graceful shutdown is always resumed. Only interruptions the agent did not record itself (crash, OOM kill, a stop timeout that forces a kill) count toward `MAX_RECENT_INTERRUPTIONS`.
## Proposal
- On SIGTERM, before the grace period ends, close the agent's own running `scan_runs` with a distinct error code, for example `RunErrorCode::Shutdown`, plus `completed_at`. Startup resumes these, and they do not count in the window.
- `recover_orphaned_runs` keeps closing whatever is still `running` as `Interrupted`, which now means the process ended without recording it. Only those runs count toward the limit.
- Tests:
- two graceful shutdowns in a row resume both times;
- two unrecorded interruptions within 24 h still stop the resume;
- one of each resumes.
The write on SIGTERM has to fit within `shutdown::GRACE_PERIOD` (8 s) and Docker's stop timeout. If it does not finish, the run stays `running` and is counted as unrecorded. The scan stops safely either way, but it may be resumed less often.
## Related
- #65: agent lifecycle, startup recovery and resume.
sharang
added the bug label 2026-11-05 15:50:19 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What happens
resume_interrupted_scans(compliance-agent/src/lifecycle.rs) does not start a scan again once it has been interrupted more than once (MAX_RECENT_INTERRUPTIONS = 1) within 24 hours. The limit is meant to stop a loop where the scan itself stops the agent, through out-of-memory or a crash. Butrecover_orphaned_runscloses every open run asinterruptedat startup, whatever ended the previous process. So a deploy restart (SIGTERM from Orca) counts the same as a crash. Two deploys in one day during a long scan are enough to drop it until the next scheduled run.Seen on prod, 2026-11-05 (target
6ae9aa2160f5d8045fc570a7)interrupted, scan resumed (resumed=1)interrupted, thennot resuming a scan interrupted again within a day; the next scheduled run trieswithinterruptions=2,resumed=0Both interruptions were planned deploys, not crashes. The target went about 5 hours without a complete scan. Everything that waits for a complete scan waited too, such as closing CVE issues the scan no longer finds.
Expected
A scan stopped by a graceful shutdown is always resumed. Only interruptions the agent did not record itself (crash, OOM kill, a stop timeout that forces a kill) count toward
MAX_RECENT_INTERRUPTIONS.Proposal
scan_runswith a distinct error code, for exampleRunErrorCode::Shutdown, pluscompleted_at. Startup resumes these, and they do not count in the window.recover_orphaned_runskeeps closing whatever is stillrunningasInterrupted, which now means the process ended without recording it. Only those runs count toward the limit.The write on SIGTERM has to fit within
shutdown::GRACE_PERIOD(8 s) and Docker's stop timeout. If it does not finish, the run staysrunningand is counted as unrecorded. The scan stops safely either way, but it may be resumed less often.Related