🐛 use DeleteCompletedJobs to preserve active scans during CronJob updates#1385
Merged
chris-rock merged 1 commit intomainfrom Feb 9, 2026
Merged
🐛 use DeleteCompletedJobs to preserve active scans during CronJob updates#1385chris-rock merged 1 commit intomainfrom
chris-rock merged 1 commit intomainfrom
Conversation
…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>
imilchev
approved these changes
Feb 9, 2026
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DeleteAllOfwithDeleteCompletedJobsin all 4 CronJob update paths (k8s_scan local, k8s_scan external, container_image, nodes)DeleteCompletedJobsutility added in 🐛 preserve active jobs when cleaning up completed scan jobs #1377, which was previously unused in production codeContext
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
DeleteAllOfwhich killed all Jobs including actively running scans. This was disruptive for long-running scans.The
DeleteCompletedJobsfunction from #1377 already handles this correctly — it skips Jobs withStatus.Active > 0and 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
make test)make lint)make lint/actions)🤖 Generated with Claude Code