From e11507de5a5412a2e8fe5753d82f951d0243ee8d Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Tue, 1 Mar 2022 14:29:04 +0100 Subject: [PATCH] Show hostname in error message when data is missing --- metricdata/cc-metric-store.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/metricdata/cc-metric-store.go b/metricdata/cc-metric-store.go index 43f44c5..99ca148 100644 --- a/metricdata/cc-metric-store.go +++ b/metricdata/cc-metric-store.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "net/http" + "strings" "time" "github.com/ClusterCockpit/cc-backend/config" @@ -146,6 +147,7 @@ func (ccms *CCMetricStore) LoadData(job *schema.Job, metrics []string, scopes [] return nil, err } + var errors []string var jobData schema.JobData = make(schema.JobData) for i, row := range resBody.Results { query := req.Queries[i] @@ -169,7 +171,8 @@ func (ccms *CCMetricStore) LoadData(job *schema.Job, metrics []string, scopes [] for _, res := range row { if res.Error != nil { - return nil, fmt.Errorf("cc-metric-store error while fetching %s: %s", metric, *res.Error) + errors = append(errors, fmt.Sprintf("failed to fetch '%s' from host '%s': %s", query.Metric, query.Hostname, *res.Error)) + continue } id := (*int)(nil) @@ -199,6 +202,10 @@ func (ccms *CCMetricStore) LoadData(job *schema.Job, metrics []string, scopes [] } } + if len(errors) != 0 { + return jobData, fmt.Errorf("cc-metric-store: errors: %s", strings.Join(errors, ",")) + } + return jobData, nil }