chore: health endpoint related changes (#2275)

This commit is contained in:
Prashant Shahi 2023-02-28 23:42:21 +05:30 committed by GitHub
parent b0d5b15330
commit 995e45713c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 20 deletions

View File

@ -156,7 +156,7 @@ services:
- TELEMETRY_ENABLED=true
- DEPLOYMENT_TYPE=docker-swarm
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/version"]
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"]
interval: 30s
timeout: 5s
retries: 3

View File

@ -28,7 +28,7 @@ services:
- "8080:8080"
restart: on-failure
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/version"]
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"]
interval: 30s
timeout: 5s
retries: 3

View File

@ -174,7 +174,7 @@ services:
- DEPLOYMENT_TYPE=docker-standalone-amd
restart: on-failure
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/version"]
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"]
interval: 30s
timeout: 5s
retries: 3

View File

@ -1704,7 +1704,7 @@ func (aH *APIHandler) getHealth(w http.ResponseWriter, r *http.Request) {
if ok {
err := aH.reader.CheckClickHouse(r.Context())
if err != nil {
aH.HandleError(w, err, http.StatusServiceUnavailable)
RespondError(w, &model.ApiError{Err: err, Typ: model.ErrorStatusServiceUnavailable}, nil)
return
}
}

View File

@ -49,19 +49,20 @@ func (a *ApiError) IsNil() bool {
type ErrorType string
const (
ErrorNone ErrorType = ""
ErrorTimeout ErrorType = "timeout"
ErrorCanceled ErrorType = "canceled"
ErrorExec ErrorType = "execution"
ErrorBadData ErrorType = "bad_data"
ErrorInternal ErrorType = "internal"
ErrorUnavailable ErrorType = "unavailable"
ErrorNotFound ErrorType = "not_found"
ErrorNotImplemented ErrorType = "not_implemented"
ErrorUnauthorized ErrorType = "unauthorized"
ErrorForbidden ErrorType = "forbidden"
ErrorConflict ErrorType = "conflict"
ErrorStreamingNotSupported ErrorType = "streaming is not supported"
ErrorNone ErrorType = ""
ErrorTimeout ErrorType = "timeout"
ErrorCanceled ErrorType = "canceled"
ErrorExec ErrorType = "execution"
ErrorBadData ErrorType = "bad_data"
ErrorInternal ErrorType = "internal"
ErrorUnavailable ErrorType = "unavailable"
ErrorNotFound ErrorType = "not_found"
ErrorNotImplemented ErrorType = "not_implemented"
ErrorUnauthorized ErrorType = "unauthorized"
ErrorForbidden ErrorType = "forbidden"
ErrorConflict ErrorType = "conflict"
ErrorStreamingNotSupported ErrorType = "streaming is not supported"
ErrorStatusServiceUnavailable ErrorType = "service unavailable"
)
// BadRequest returns a ApiError object of bad request

View File

@ -6,7 +6,7 @@ func IgnoredPaths() map[string]struct{} {
"/api/v1/version": {},
"/api/v1/query_range": {},
"/api/v2/metrics/query_range": {},
"/api/v1/services/list": {},
"/api/v1/health": {},
}
return ignoredPaths

View File

@ -90,7 +90,7 @@ func startCluster() error {
client := http.Client{}
for i := 0; i < 10; i++ {
if _, err := client.Get("http://localhost:8180/api/v1/version"); err != nil {
if _, err := client.Get("http://localhost:8180/api/v1/health"); err != nil {
time.Sleep(2 * time.Second)
} else {
log.Printf("CLUSTER UP\n")

View File

@ -162,7 +162,7 @@ services:
- DEPLOYMENT_TYPE=docker-standalone-amd
restart: on-failure
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/version"]
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"]
interval: 30s
timeout: 5s
retries: 3