Skip to content

🐛 use DeleteCompletedJobs to preserve active scans during CronJob updates#1385

Merged
chris-rock merged 1 commit intomainfrom
use-delete-completed-jobs
Feb 9, 2026
Merged

🐛 use DeleteCompletedJobs to preserve active scans during CronJob updates#1385
chris-rock merged 1 commit intomainfrom
use-delete-completed-jobs

Conversation

@chris-rock
Copy link
Copy Markdown
Member

Summary

  • Replaces DeleteAllOf with DeleteCompletedJobs in all 4 CronJob update paths (k8s_scan local, k8s_scan external, container_image, nodes)
  • Running scan jobs are no longer killed when a CronJob spec changes; only completed/failed jobs are cleaned up
  • This wires up the DeleteCompletedJobs utility added in 🐛 preserve active jobs when cleaning up completed scan jobs #1377, which was previously unused in production code

Context

When the operator reconciles a CronJob spec change (e.g. new image, new config), it needs to clean up old Jobs since they won't pick up the new spec. Previously this used DeleteAllOf which killed all Jobs including actively running scans. This was disruptive for long-running scans.

The DeleteCompletedJobs function from #1377 already handles this correctly — it skips Jobs with Status.Active > 0 and only deletes completed/failed ones. Active scans finish naturally with the old config, and the next scheduled run picks up the new spec.

Test plan

  • All unit tests pass (make test)
  • Go linting passes (make lint)
  • Actions linting passes (make lint/actions)
  • Verify running scans are not interrupted when CronJob spec changes
  • Verify completed jobs are still cleaned up on spec change

🤖 Generated with Claude Code

…ates

Replace DeleteAllOf with DeleteCompletedJobs in all controllers so that
running scan jobs are not killed when a CronJob spec changes. Completed
and failed jobs are still cleaned up immediately, while active jobs are
left to finish naturally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 9, 2026

Test Results

  5 files  +  3   41 suites  +39   32m 49s ⏱️ + 32m 26s
301 tests +299  301 ✅ +301  0 💤  - 1  0 ❌  - 1 
320 runs  +316  318 ✅ +318  2 💤 ±0  0 ❌  - 2 

Results for commit bb58a54. ± Comparison against base commit 637c4fa.

@chris-rock chris-rock merged commit 50c7737 into main Feb 9, 2026
24 checks passed
@chris-rock chris-rock deleted the use-delete-completed-jobs branch February 9, 2026 11:45
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 9, 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