mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
liveness returns "busy" if queued requests > available capacity (#16719)
This commit is contained in:
parent
bfedea9bad
commit
ae029191a3
@ -1520,7 +1520,7 @@ var errorCodes = errorCodeMap{
|
|||||||
HTTPStatusCode: http.StatusBadRequest,
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
},
|
},
|
||||||
ErrBusy: {
|
ErrBusy: {
|
||||||
Code: "Busy",
|
Code: "ServerBusy",
|
||||||
Description: "The service is unavailable. Please retry.",
|
Description: "The service is unavailable. Please retry.",
|
||||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||||
},
|
},
|
||||||
|
File diff suppressed because one or more lines are too long
@ -227,6 +227,13 @@ func (t *apiConfig) getClusterDeadline() time.Duration {
|
|||||||
return t.clusterDeadline
|
return t.clusterDeadline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *apiConfig) getRequestsPoolCapacity() int {
|
||||||
|
t.mu.RLock()
|
||||||
|
defer t.mu.RUnlock()
|
||||||
|
|
||||||
|
return cap(t.requestsPool)
|
||||||
|
}
|
||||||
|
|
||||||
func (t *apiConfig) getRequestsPool() (chan struct{}, time.Duration) {
|
func (t *apiConfig) getRequestsPool() (chan struct{}, time.Duration) {
|
||||||
t.mu.RLock()
|
t.mu.RLock()
|
||||||
defer t.mu.RUnlock()
|
defer t.mu.RUnlock()
|
||||||
|
@ -106,6 +106,17 @@ func LivenessCheckHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set(xhttp.MinIOServerStatus, unavailable)
|
w.Header().Set(xhttp.MinIOServerStatus, unavailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if int(globalHTTPStats.loadRequestsInQueue()) > globalAPIConfig.getRequestsPoolCapacity() {
|
||||||
|
apiErr := getAPIError(ErrBusy)
|
||||||
|
switch r.Method {
|
||||||
|
case http.MethodHead:
|
||||||
|
writeResponse(w, apiErr.HTTPStatusCode, nil, mimeNone)
|
||||||
|
case http.MethodGet:
|
||||||
|
writeErrorResponse(r.Context(), w, apiErr, r.URL)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Verify if KMS is reachable if its configured
|
// Verify if KMS is reachable if its configured
|
||||||
if GlobalKMS != nil {
|
if GlobalKMS != nil {
|
||||||
ctx, cancel := context.WithTimeout(r.Context(), time.Minute)
|
ctx, cancel := context.WithTimeout(r.Context(), time.Minute)
|
||||||
|
@ -255,6 +255,10 @@ type HTTPStats struct {
|
|||||||
totalS3Canceled HTTPAPIStats
|
totalS3Canceled HTTPAPIStats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (st *HTTPStats) loadRequestsInQueue() int32 {
|
||||||
|
return atomic.LoadInt32(&st.s3RequestsInQueue)
|
||||||
|
}
|
||||||
|
|
||||||
func (st *HTTPStats) addRequestsInQueue(i int32) {
|
func (st *HTTPStats) addRequestsInQueue(i int32) {
|
||||||
atomic.AddInt32(&st.s3RequestsInQueue, i)
|
atomic.AddInt32(&st.s3RequestsInQueue, i)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user