mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-07-22 06:50:38 +02:00
fix: wire NodeProvider into CLI checkpoint cleanup path
The -cleanup-checkpoints CLI flag called CleanupCheckpoints without initializing the MemoryStore singleton or setting its NodeProvider, so it silently fell back to legacy clean-everything behavior and could delete checkpoints for hosts with running jobs. Inject the job repository as NodeProvider the same way runServer does, so the CLI path also skips used hosts. Also update SetNodeProvider's doc comment, which only mentioned Free but is now also consulted by FromCheckpoint and CleanupCheckpoints. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -589,6 +589,11 @@ func run() error {
|
||||
cleanupDir = metricstore.Keys.Cleanup.RootDir
|
||||
}
|
||||
|
||||
// Wire the job repository as NodeProvider so cleanup skips hosts
|
||||
// with running jobs (same injection as runServer).
|
||||
metricstore.InitMetrics(metricstore.BuildMetricList())
|
||||
metricstore.GetMemoryStore().SetNodeProvider(repository.GetJobRepository())
|
||||
|
||||
cclog.Infof("Cleaning up checkpoints older than %s...", from.Format(time.RFC3339))
|
||||
n, err := metricstore.CleanupCheckpoints(
|
||||
metricstore.Keys.Checkpoints.RootDir, cleanupDir, from.Unix(), deleteMode)
|
||||
|
||||
Reference in New Issue
Block a user