[filer] replace an invalid methods in a metric with an invalid one (#5378)
fix: replace an invalid methods in a metric with an invalid one for filer
This commit is contained in:
committed by
GitHub
parent
604091a480
commit
54ee73287d
@@ -63,11 +63,11 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
stats.FilerRequestHistogram.WithLabelValues(stats.ChunkProxy).Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues(stats.ChunkProxy).Observe(time.Since(start).Seconds())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
requestMethod := r.Method
|
||||||
defer func() {
|
defer func(method *string) {
|
||||||
stats.FilerRequestCounter.WithLabelValues(r.Method, strconv.Itoa(statusRecorder.Status)).Inc()
|
stats.FilerRequestCounter.WithLabelValues(*method, strconv.Itoa(statusRecorder.Status)).Inc()
|
||||||
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues(*method).Observe(time.Since(start).Seconds())
|
||||||
}()
|
}(&requestMethod)
|
||||||
|
|
||||||
isReadHttpCall := r.Method == http.MethodGet || r.Method == http.MethodHead
|
isReadHttpCall := r.Method == http.MethodGet || r.Method == http.MethodHead
|
||||||
if !fs.maybeCheckJwtAuthorization(r, !isReadHttpCall) {
|
if !fs.maybeCheckJwtAuthorization(r, !isReadHttpCall) {
|
||||||
@@ -113,6 +113,7 @@ func (fs *FilerServer) filerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
fs.PostHandler(w, r, contentLength)
|
fs.PostHandler(w, r, contentLength)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
requestMethod = "INVALID"
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,11 +147,11 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
w.Header().Set("Access-Control-Allow-Headers", "OPTIONS, GET, HEAD")
|
w.Header().Set("Access-Control-Allow-Headers", "OPTIONS, GET, HEAD")
|
||||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||||
}
|
}
|
||||||
|
requestMethod := r.Method
|
||||||
defer func() {
|
defer func(method *string) {
|
||||||
stats.FilerRequestCounter.WithLabelValues(r.Method, strconv.Itoa(statusRecorder.Status)).Inc()
|
stats.FilerRequestCounter.WithLabelValues(*method, strconv.Itoa(statusRecorder.Status)).Inc()
|
||||||
stats.FilerRequestHistogram.WithLabelValues(r.Method).Observe(time.Since(start).Seconds())
|
stats.FilerRequestHistogram.WithLabelValues(*method).Observe(time.Since(start).Seconds())
|
||||||
}()
|
}(&requestMethod)
|
||||||
// We handle OPTIONS first because it never should be authenticated
|
// We handle OPTIONS first because it never should be authenticated
|
||||||
if r.Method == http.MethodOptions {
|
if r.Method == http.MethodOptions {
|
||||||
OptionsHandler(w, r, true)
|
OptionsHandler(w, r, true)
|
||||||
@@ -168,6 +169,7 @@ func (fs *FilerServer) readonlyFilerHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
case http.MethodGet, http.MethodHead:
|
case http.MethodGet, http.MethodHead:
|
||||||
fs.GetOrHeadHandler(w, r)
|
fs.GetOrHeadHandler(w, r)
|
||||||
default:
|
default:
|
||||||
|
requestMethod = "INVALID"
|
||||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user