2018-03-12 02:16:53 -04:00
|
|
|
/*
|
2019-04-09 14:39:42 -04:00
|
|
|
* MinIO Cloud Storage, (C) 2018 MinIO, Inc.
|
2018-03-12 02:16:53 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2018-04-21 22:23:54 -04:00
|
|
|
"github.com/gorilla/mux"
|
2018-03-12 02:16:53 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
healthCheckPath = "/health"
|
|
|
|
healthCheckLivenessPath = "/live"
|
|
|
|
healthCheckReadinessPath = "/ready"
|
2020-06-30 14:28:27 -04:00
|
|
|
healthCheckClusterPath = "/cluster"
|
2018-03-12 02:16:53 -04:00
|
|
|
healthCheckPathPrefix = minioReservedBucketPath + healthCheckPath
|
|
|
|
)
|
|
|
|
|
|
|
|
// registerHealthCheckRouter - add handler functions for liveness and readiness routes.
|
2018-04-21 22:23:54 -04:00
|
|
|
func registerHealthCheckRouter(router *mux.Router) {
|
2018-03-12 02:16:53 -04:00
|
|
|
|
|
|
|
// Healthcheck router
|
2018-04-21 22:23:54 -04:00
|
|
|
healthRouter := router.PathPrefix(healthCheckPathPrefix).Subrouter()
|
2018-03-12 02:16:53 -04:00
|
|
|
|
2020-06-30 14:28:27 -04:00
|
|
|
// Cluster check handler to verify cluster is active
|
|
|
|
healthRouter.Methods(http.MethodGet).Path(healthCheckClusterPath).HandlerFunc(httpTraceAll(ClusterCheckHandler))
|
|
|
|
|
2018-03-12 02:16:53 -04:00
|
|
|
// Liveness handler
|
2018-06-07 13:41:13 -04:00
|
|
|
healthRouter.Methods(http.MethodGet).Path(healthCheckLivenessPath).HandlerFunc(httpTraceAll(LivenessCheckHandler))
|
|
|
|
healthRouter.Methods(http.MethodHead).Path(healthCheckLivenessPath).HandlerFunc(httpTraceAll(LivenessCheckHandler))
|
2018-03-12 02:16:53 -04:00
|
|
|
|
|
|
|
// Readiness handler
|
2018-06-07 13:41:13 -04:00
|
|
|
healthRouter.Methods(http.MethodGet).Path(healthCheckReadinessPath).HandlerFunc(httpTraceAll(ReadinessCheckHandler))
|
|
|
|
healthRouter.Methods(http.MethodHead).Path(healthCheckReadinessPath).HandlerFunc(httpTraceAll(ReadinessCheckHandler))
|
2018-03-12 02:16:53 -04:00
|
|
|
}
|