Skip to content

🐛 preserve active jobs when cleaning up completed scan jobs#1377

Merged
chris-rock merged 3 commits intomainfrom
fix/preserve-active-jobs
Feb 5, 2026
Merged

🐛 preserve active jobs when cleaning up completed scan jobs#1377
chris-rock merged 3 commits intomainfrom
fix/preserve-active-jobs

Conversation

@chris-rock
Copy link
Member

Summary

  • Adds DeleteCompletedJobs function that only deletes completed/failed jobs
  • Preserves active/running jobs to avoid interrupting in-progress scans
  • Includes comprehensive test coverage

Context

Previously the controller would delete all jobs when updating CronJob specs, including active/running jobs. This could interrupt long-running scans unexpectedly.

Test plan

  • Unit tests pass for new DeleteCompletedJobs function
  • Verify running scans are not interrupted when CronJob spec changes
  • Verify completed jobs are cleaned up properly

Extracted from #1337 - Original author: @jpaodev

@chris-rock chris-rock changed the title fix: preserve active jobs when cleaning up completed scan jobs 🐛 preserve active jobs when cleaning up completed scan jobs Feb 5, 2026
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Test Results

  5 files  ± 0   41 suites  ±0   35m 43s ⏱️ + 4m 54s
292 tests +10  292 ✅ +10  0 💤 ±0  0 ❌ ±0 
311 runs  +10  309 ✅ +10  2 💤 ±0  0 ❌ ±0 

Results for commit f546790. ± Comparison against base commit 187d055.

♻️ This comment has been updated with latest results.

jpaodev and others added 2 commits February 5, 2026 20:52
Previously the controller would delete all jobs when updating CronJob
specs, including active/running jobs. This could interrupt in-progress
scans.

The new DeleteCompletedJobs function only deletes jobs that have
completed (succeeded or failed), preserving any active jobs.

Includes tests for the new behavior.
@chris-rock chris-rock force-pushed the fix/preserve-active-jobs branch from dd30f24 to a094bc1 Compare February 5, 2026 19:56
- Handle NotFound errors on delete (race condition with TTL controller)
- Change log level to V(1) to reduce noise during normal operation
- Remove unused expectedDeleted field from tests
- Add test for jobs with non-matching labels being preserved
@chris-rock chris-rock merged commit 8904ec0 into main Feb 5, 2026
23 checks passed
@chris-rock chris-rock deleted the fix/preserve-active-jobs branch February 5, 2026 22:41
@github-actions github-actions bot locked and limited conversation to collaborators Feb 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants