Return partial data from MetricDataRepositories

This commit is contained in:
Lou Knauer 2022-03-01 16:01:25 +01:00
parent 6ad74e918e
commit f81ccb7656
2 changed files with 14 additions and 1 deletions

View File

@ -200,6 +200,14 @@ func (ccms *CCMetricStore) LoadData(job *schema.Job, metrics []string, scopes []
Data: res.Data, Data: res.Data,
}) })
} }
// So that one can later check len(jobData):
if len(jobMetric.Series) == 0 {
delete(jobData[metric], scope)
if len(jobData[metric]) == 0 {
delete(jobData, metric)
}
}
} }
if len(errors) != 0 { if len(errors) != 0 {

View File

@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/ClusterCockpit/cc-backend/config" "github.com/ClusterCockpit/cc-backend/config"
"github.com/ClusterCockpit/cc-backend/log"
"github.com/ClusterCockpit/cc-backend/schema" "github.com/ClusterCockpit/cc-backend/schema"
"github.com/iamlouk/lrucache" "github.com/iamlouk/lrucache"
) )
@ -86,8 +87,12 @@ 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 {
log.Errorf("partial error: %s (some data will be returned)", err.Error())
} else {
return err, 0, 0 return err, 0, 0
} }
}
} else { } else {
jd, err = loadFromArchive(job) jd, err = loadFromArchive(job)
if err != nil { if err != nil {