Add limiting ability to log fields (#24251)

This commit is contained in:
Ibrahim Serdar Acikgoz
2023-09-28 19:28:40 +03:00
committed by GitHub
parent 703ad006ad
commit 53a0f8da27
5 changed files with 12 additions and 7 deletions

View File

@@ -152,13 +152,12 @@ func (backend *LocalBackend) ServeImage(w http.ResponseWriter, req *http.Request
resp, err := backend.client.Do(actualReq)
if err != nil {
msg := fmt.Sprintf("error fetching remote image: %v", err)
mlog.Warn(msg)
mlog.Warn("error fetching remote image", mlog.Err(err))
statusCode := http.StatusInternalServerError
if e, ok := err.(net.Error); ok && e.Timeout() {
statusCode = http.StatusGatewayTimeout
}
http.Error(w, msg, statusCode)
http.Error(w, fmt.Sprintf("error fetching remote image: %v", err), statusCode)
return
}
// close the original resp.Body, even if we wrap it in a NopCloser below