mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-07-22 06:50:38 +02:00
feat: pass NodeProvider to metricstore Init
Setting the provider after Init left the checkpoint restore inside Init without job information and forced callers to pre-call InitMetrics and SetNodeProvider in the right order. Init now receives the provider as a parameter and injects it before the restore, so the ordering is enforced by the signature. SetNodeProvider remains for callers that do not run Init (tests, -cleanup-checkpoints). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -367,15 +367,10 @@ func runServer(ctx context.Context) error {
|
||||
haveMetricstore := false
|
||||
mscfg := ccconf.GetPackageConfig("metric-store")
|
||||
if mscfg != nil {
|
||||
metrics := metricstore.BuildMetricList()
|
||||
// The NodeProvider MUST be set before Init: the checkpoint load inside
|
||||
// Init consults it to load the full history for nodes with running
|
||||
// jobs. InitMetrics is sync.Once-guarded, so the second call inside
|
||||
// Init is a no-op. The repository is injected as NodeProvider to
|
||||
// break the import cycle.
|
||||
metricstore.InitMetrics(metrics)
|
||||
metricstore.GetMemoryStore().SetNodeProvider(repository.GetJobRepository())
|
||||
metricstore.Init(mscfg, metrics, &wg)
|
||||
// The repository is injected as NodeProvider (breaking the import
|
||||
// cycle) so the checkpoint load inside Init can fetch the full
|
||||
// history for nodes with running jobs.
|
||||
metricstore.Init(mscfg, metricstore.BuildMetricList(), repository.GetJobRepository(), &wg)
|
||||
|
||||
metricstore.MetricStoreHandle = &metricstore.InternalMetricStore{}
|
||||
haveMetricstore = true
|
||||
|
||||
Reference in New Issue
Block a user