Allow partially missing data on system view

This commit is contained in:
Lou Knauer 2022-03-09 14:27:47 +01:00
parent 8facef21a9
commit a9f6da7595
2 changed files with 13 additions and 5 deletions

View File

@ -211,7 +211,7 @@ func (ccms *CCMetricStore) LoadData(job *schema.Job, metrics []string, scopes []
} }
if len(errors) != 0 { if len(errors) != 0 {
return jobData, fmt.Errorf("cc-metric-store: errors: %s", strings.Join(errors, ",")) return jobData, fmt.Errorf("cc-metric-store: %s", strings.Join(errors, ", "))
} }
return jobData, nil return jobData, nil
@ -528,7 +528,7 @@ func (ccms *CCMetricStore) LoadNodeData(cluster, partition string, metrics, node
return nil, err return nil, err
} }
_ = resBody var errors []string
data := make(map[string]map[string][]*schema.JobMetric) data := make(map[string]map[string][]*schema.JobMetric)
for i, res := range resBody.Results { for i, res := range resBody.Results {
var query ApiQuery var query ApiQuery
@ -541,7 +541,7 @@ func (ccms *CCMetricStore) LoadNodeData(cluster, partition string, metrics, node
metric := ccms.toLocalName(query.Metric) metric := ccms.toLocalName(query.Metric)
qdata := res[0] qdata := res[0]
if qdata.Error != nil { if qdata.Error != nil {
return nil, fmt.Errorf("fetching %s for node %s failed: %s", metric, query.Hostname, *qdata.Error) errors = append(errors, fmt.Sprintf("fetching %s for node %s failed: %s", metric, query.Hostname, *qdata.Error))
} }
if qdata.Avg.IsNaN() || qdata.Min.IsNaN() || qdata.Max.IsNaN() { if qdata.Avg.IsNaN() || qdata.Min.IsNaN() || qdata.Max.IsNaN() {
@ -574,5 +574,9 @@ func (ccms *CCMetricStore) LoadNodeData(cluster, partition string, metrics, node
}) })
} }
if len(errors) != 0 {
return data, fmt.Errorf("cc-metric-store: %s", strings.Join(errors, ", "))
}
return data, nil return data, nil
} }

View File

@ -88,7 +88,7 @@ func LoadData(job *schema.Job, metrics []string, scopes []schema.MetricScope, ct
jd, err = repo.LoadData(job, metrics, scopes, ctx) jd, err = repo.LoadData(job, metrics, scopes, ctx)
if err != nil { if err != nil {
if len(jd) != 0 { if len(jd) != 0 {
log.Errorf("partial error: %s (some data will be returned)", err.Error()) log.Errorf("partial error: %s", err.Error())
} else { } else {
return err, 0, 0 return err, 0, 0
} }
@ -174,7 +174,11 @@ func LoadNodeData(cluster, partition string, metrics, nodes []string, scopes []s
data, err := repo.LoadNodeData(cluster, partition, metrics, nodes, scopes, from, to, ctx) data, err := repo.LoadNodeData(cluster, partition, metrics, nodes, scopes, from, to, ctx)
if err != nil { if err != nil {
return nil, err if len(data) != 0 {
log.Errorf("partial error: %s", err.Error())
} else {
return nil, err
}
} }
if data == nil { if data == nil {