mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-07-27 00:37:14 +02:00
Adopt cc-lib hierarchical JobData/Statistics structs
cc-lib changed JobData, ScopedJobStats and Job.Statistics from flat maps to structs (a .Metrics map plus array-valued Groups) to represent filesystem (and future interconnect) metric groups. Migrate all construction, indexing and iteration to the new API across the archive backends, metricstore query path, metric dispatcher, archiver, importer, tagger, taskmanager, repository and API layers. Semantics: DecodeJobStats now projects JobData.Groups into ScopedJobStats.Groups, and the archiver derives per-filesystem node-scope statistics into Job.Statistics.Groups. deepCopy, resampling and the metric/scope filter are group-aware. The metricstore internal storage (buffers, selector tree, checkpoint/parquet) is unchanged; all conversion stays at the LoadData/archive-codec seam. Note: requires the corresponding cc-lib release; bump the cc-lib dependency version once tagged (a local go.mod replace was used during development and is intentionally not committed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -65,11 +65,11 @@ func ArchiveJob(job *schema.Job, ctx context.Context) (*schema.Job, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
job.Statistics = make(map[string]schema.JobStatistics)
|
||||
job.Statistics = schema.JobStatisticsSet{Metrics: make(map[string]schema.JobStatistics)}
|
||||
|
||||
for metric, data := range jobData {
|
||||
for metric, data := range jobData.Metrics {
|
||||
avg, min, max := 0.0, math.MaxFloat32, -math.MaxFloat32
|
||||
nodeData, ok := data["node"]
|
||||
nodeData, ok := data[schema.MetricScopeNode]
|
||||
if !ok {
|
||||
// This should never happen ?
|
||||
continue
|
||||
@@ -82,7 +82,7 @@ func ArchiveJob(job *schema.Job, ctx context.Context) (*schema.Job, error) {
|
||||
}
|
||||
|
||||
// Round AVG Result to 2 Digits
|
||||
job.Statistics[metric] = schema.JobStatistics{
|
||||
job.Statistics.Metrics[metric] = schema.JobStatistics{
|
||||
Unit: schema.Unit{
|
||||
Prefix: archive.GetMetricConfig(job.Cluster, metric).Unit.Prefix,
|
||||
Base: archive.GetMetricConfig(job.Cluster, metric).Unit.Base,
|
||||
@@ -93,5 +93,43 @@ func ArchiveJob(job *schema.Job, ctx context.Context) (*schema.Job, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the same node-scope statistics for each array-valued metric group
|
||||
// instance (e.g. per-filesystem) and attach it as a group in the statistics
|
||||
// set so it round-trips into the job-meta "statistics" JSON.
|
||||
for _, group := range jobData.Groups {
|
||||
for _, inst := range group.Instances {
|
||||
instStats := make(map[string]schema.JobStatistics)
|
||||
for metric, data := range inst.Metrics {
|
||||
avg, min, max := 0.0, math.MaxFloat32, -math.MaxFloat32
|
||||
nodeData, ok := data[schema.MetricScopeNode]
|
||||
if !ok {
|
||||
// This should never happen ?
|
||||
continue
|
||||
}
|
||||
|
||||
for _, series := range nodeData.Series {
|
||||
avg += series.Statistics.Avg
|
||||
min = math.Min(min, series.Statistics.Min)
|
||||
max = math.Max(max, series.Statistics.Max)
|
||||
}
|
||||
|
||||
// Prefer the unit from a MetricConfig if one exists, otherwise
|
||||
// fall back to the unit already present on the JobMetric.
|
||||
unit := nodeData.Unit
|
||||
if mc := archive.GetMetricConfig(job.Cluster, metric); mc != nil {
|
||||
unit = schema.Unit{Prefix: mc.Unit.Prefix, Base: mc.Unit.Base}
|
||||
}
|
||||
|
||||
instStats[metric] = schema.JobStatistics{
|
||||
Unit: unit,
|
||||
Avg: (math.Round((avg/float64(job.NumNodes))*100) / 100),
|
||||
Min: min,
|
||||
Max: max,
|
||||
}
|
||||
}
|
||||
job.Statistics.AddGroupInstance(group.Key, inst.Name, inst.Type, instStats)
|
||||
}
|
||||
}
|
||||
|
||||
return job, archive.GetHandle().ImportJob(job, &jobData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user