From f8576d5b5d192b60e2af85e0f1d4b50e2bcf3169 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Sat, 27 Feb 2021 20:18:34 +0000 Subject: [PATCH] Return error from upstream when calling list functions This is currently being hidden and needs to be bubbled up into the logs to show an issue with calling list functions during a deletion in faasd. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- gateway/metrics/add_metrics.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gateway/metrics/add_metrics.go b/gateway/metrics/add_metrics.go index 0030e17a..ef3b0ff5 100644 --- a/gateway/metrics/add_metrics.go +++ b/gateway/metrics/add_metrics.go @@ -28,15 +28,19 @@ func AddMetricsHandler(handler http.HandlerFunc, prometheusQuery PrometheusQuery } defer upstreamCall.Body.Close() + upstreamBody, _ := ioutil.ReadAll(upstreamCall.Body) if recorder.Code != http.StatusOK { + log.Printf("List functions responded with code %d, body: %s", + recorder.Code, + string(upstreamBody)) + w.Header().Set("Content-Type", "text/plain") w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte(fmt.Sprintf("Error pulling metrics from provider/backend. Status code: %d", recorder.Code))) + w.Write([]byte(fmt.Sprintf("List functions responded with code %d", recorder.Code))) return } - upstreamBody, _ := ioutil.ReadAll(upstreamCall.Body) var functions []types.FunctionStatus err := json.Unmarshal(upstreamBody, &functions)