Skip to content

Commit

Permalink
Update error handling for empty metrics responses in exporter
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Apr 2, 2024
1 parent 667577f commit b22cb63
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gateway/metrics/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit b22cb63

Please sign in to comment.