From 267f183fc8880bfb8d673599275c2d164aedc525 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas <634494+krishnasrinivas@users.noreply.github.com> Date: Sat, 19 Jan 2019 20:58:36 -0800 Subject: [PATCH] Do not do StorageInfo() and ListBuckets() for FS/Erasure in health check handler (#7090) Health checking programs very frequently use /minio/health/live to check health, hence we can avoid doing StorageInfo() and ListBuckets() for FS/Erasure backend. --- cmd/healthcheck-handler.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/healthcheck-handler.go b/cmd/healthcheck-handler.go index 5364d496e..4bc72c307 100644 --- a/cmd/healthcheck-handler.go +++ b/cmd/healthcheck-handler.go @@ -56,18 +56,21 @@ func LivenessCheckHandler(w http.ResponseWriter, r *http.Request) { return } - s := objLayer.StorageInfo(ctx) - // Gateways don't provide disk info, also handle special case for NAS gateway. - if s.Backend.Type == Unknown || s.Backend.Type == BackendFS { - // ListBuckets to confirm gateway backend is up - if _, err := objLayer.ListBuckets(ctx); err != nil { - writeResponse(w, http.StatusServiceUnavailable, nil, mimeNone) + if !globalIsXL && !globalIsDistXL { + s := objLayer.StorageInfo(ctx) + // Gateways don't provide disk info. + if s.Backend.Type == Unknown { + // ListBuckets to confirm gateway backend is up + if _, err := objLayer.ListBuckets(ctx); err != nil { + writeResponse(w, http.StatusServiceUnavailable, nil, mimeNone) + return + } + writeResponse(w, http.StatusOK, nil, mimeNone) return } - writeResponse(w, http.StatusOK, nil, mimeNone) - return } + // For FS and Erasure backend, check if local disks are up. var totalLocalDisks int var erroredDisks int for _, endpoint := range globalEndpoints {