Update error handling for empty metrics responses in exporter

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd) 2024-04-02 12:20:36 +01:00
parent 667577f3ce
commit b22cb639fe

View File

@ -167,7 +167,9 @@ func (e *Exporter) getFunctions(endpointURL url.URL, namespace string) ([]types.
} else {
body = b
}
} else {
}
if len(body) == 0 {
return services, fmt.Errorf("no response body from /system/functions")
}
@ -211,6 +213,10 @@ func (e *Exporter) getNamespaces(endpointURL url.URL) ([]string, error) {
}
}
if len(body) == 0 {
return namespaces, fmt.Errorf("no response body from /system/namespaces")
}
if err := json.Unmarshal(body, &namespaces); err != nil {
return namespaces, fmt.Errorf("error unmarshalling response: %s, error: %s", string(body), err)
}