Skip to content

Commit b22cb63

Browse files
committed
Update error handling for empty metrics responses in exporter
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 667577f commit b22cb63

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gateway/metrics/exporter.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ func (e *Exporter) getFunctions(endpointURL url.URL, namespace string) ([]types.
167167
} else {
168168
body = b
169169
}
170-
} else {
170+
}
171+
172+
if len(body) == 0 {
171173
return services, fmt.Errorf("no response body from /system/functions")
172174
}
173175

@@ -211,6 +213,10 @@ func (e *Exporter) getNamespaces(endpointURL url.URL) ([]string, error) {
211213
}
212214
}
213215

216+
if len(body) == 0 {
217+
return namespaces, fmt.Errorf("no response body from /system/namespaces")
218+
}
219+
214220
if err := json.Unmarshal(body, &namespaces); err != nil {
215221
return namespaces, fmt.Errorf("error unmarshalling response: %s, error: %s", string(body), err)
216222
}

0 commit comments

Comments
 (0)