admin/plugin: delete job_detail files when jobs are pruned from memory (#8722)

* admin/plugin: delete job_detail files when jobs are pruned from memory

pruneTrackedJobsLocked evicts the oldest terminal jobs from the in-memory
tracker when the total exceeds maxTrackedJobsTotal (1000). However the
dedicated per-job detail files in jobs/job_details/ were never removed,
causing them to accumulate indefinitely on disk.

Add ConfigStore.DeleteJobDetail and call it from pruneTrackedJobsLocked so
that the file is cleaned up together with the in-memory entry. Deletion
errors are logged at verbosity level 2 and do not abort the prune.

* admin/plugin: add test for DeleteJobDetail

---------

Co-authored-by: Anton Ustyugov <anton@devops>
Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
Anton
2026-03-21 23:23:32 +02:00
committed by GitHub
parent 90277ceed5
commit 7f0cf72574
3 changed files with 76 additions and 1 deletions

View File

@@ -1134,7 +1134,11 @@ func (r *Plugin) pruneTrackedJobsLocked() {
}
for i := 0; i < toDelete; i++ {
delete(r.jobs, terminalJobs[i].jobID)
jobID := terminalJobs[i].jobID
delete(r.jobs, jobID)
if err := r.store.DeleteJobDetail(jobID); err != nil {
glog.V(2).Infof("Plugin failed to delete job detail for pruned job %s: %v", jobID, err)
}
}
}