web: don't return federation errors over HTTP

We are writing federation responses streaming. So after
the first byte we wrote, the status header is fixed. We cannot
return an HTTP error for intermediate error but should just abort
and log instead.
This commit is contained in:
Fabian Reinartz 2016-12-06 15:52:50 +01:00
parent 893390e0c6
commit 9d68e81b32

View file

@ -92,7 +92,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
// creating the new one.
if protMetricFam != nil {
if err := enc.Encode(protMetricFam); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.With("err", err).Error("federation failed")
return
}
}
@ -133,7 +133,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
// Still have to ship off the last MetricFamily, if any.
if protMetricFam != nil {
if err := enc.Encode(protMetricFam); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.With("err", err).Error("federation failed")
}
}
}