Skip to content

Commit

Permalink
Return error from upstream when calling list functions
Browse files Browse the repository at this point in the history
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) <[email protected]>
  • Loading branch information
alexellis committed Feb 27, 2021
1 parent 089cd33 commit f8576d5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gateway/metrics/add_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f8576d5

Please sign in to comment.