From f81ccb76562274b56edbb80f2d1f567d51103b8b Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Tue, 1 Mar 2022 16:01:25 +0100 Subject: [PATCH] Return partial data from MetricDataRepositories --- metricdata/cc-metric-store.go | 8 ++++++++ metricdata/metricdata.go | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/metricdata/cc-metric-store.go b/metricdata/cc-metric-store.go index 99ca148..b1e69d0 100644 --- a/metricdata/cc-metric-store.go +++ b/metricdata/cc-metric-store.go @@ -200,6 +200,14 @@ func (ccms *CCMetricStore) LoadData(job *schema.Job, metrics []string, scopes [] 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 { diff --git a/metricdata/metricdata.go b/metricdata/metricdata.go index 5943ca3..361aba7 100644 --- a/metricdata/metricdata.go +++ b/metricdata/metricdata.go @@ -6,6 +6,7 @@ import ( "time" "github.com/ClusterCockpit/cc-backend/config" + "github.com/ClusterCockpit/cc-backend/log" "github.com/ClusterCockpit/cc-backend/schema" "github.com/iamlouk/lrucache" ) @@ -86,7 +87,11 @@ func LoadData(job *schema.Job, metrics []string, scopes []schema.MetricScope, ct jd, err = repo.LoadData(job, metrics, scopes, ctx) if err != nil { - return err, 0, 0 + if len(jd) != 0 { + log.Errorf("partial error: %s (some data will be returned)", err.Error()) + } else { + return err, 0, 0 + } } } else { jd, err = loadFromArchive(job)