Repository navigation
fix: delete a garbage collected Job's Pods with it - #1104
frankvollenweider wants to merge 1 commit into
Conversation
gc jobs deleted Jobs with empty DeleteOptions. For batch/v1 Jobs the API server then orphans the Job's Pods, and says so in a warning on every delete. The orphaned Pods have no ownerReferences, so nothing collects them afterwards. With the default jx-gcjobs CronJob this leaves one completed jx-boot Pod in jx-git-operator per boot Job, and they accumulate until the nodes are replaced. Delete with background propagation, as kubectl delete job does, so the garbage collector removes the Pods together with the Job. Fixes jenkins-x-plugins#1103 Signed-off-by: frankvollenweider <frank.vollenweider@wolkenreich.ch>
|
Hi @frankvollenweider. Thanks for your PR. I'm waiting for a jenkins-x-plugins member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Closing: as discussed in #1103, the boot Jobs already clean themselves up via |
Fixes #1103
jx gitops gc jobsdeleted Jobs with emptyDeleteOptions. Forbatch/v1Jobs, the API server then keeps the Job's Pods, and it warns about this on every delete:The orphaned Pods have no
ownerReferences, so nothing collects them afterwards. With the defaultjx-gcjobsCronJob (gc jobs --namespace jx-git-operator), every boot Job leaves one completedjx-boot-*Pod behind.jx-gcpodscovers onlyjx, so the Pods build up until the nodes are replaced. On our cluster that was 74 orphans in six days.Change
pkg/cmd/gc/jobs/jobs.go: delete withPropagationPolicy: Background, the same askubectl delete jobdoes. The garbage collector then removes the Pods together with the Job.pkg/cmd/gc/jobs/jobs_test.go: new test, since the command had none. It checks that only the Job past--ageis deleted and that the delete carries background propagation. The test fails without the fix.go vetandgo test ./pkg/cmd/gc/jobs/pass with Go 1.26.🤖 Generated with Claude Code