debian-mirror-gitlab/app/controllers/health_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class HealthController < ActionController::Base
2018-12-13 13:39:08 +05:30
protect_from_forgery with: :exception, prepend: true
2017-09-10 17:25:29 +05:30
include RequiresWhitelistedMonitoringClient
2017-08-17 22:00:37 +05:30
CHECKS = [
2019-12-26 22:10:19 +05:30
Gitlab::HealthChecks::MasterCheck
].freeze
ALL_CHECKS = [
*CHECKS,
2017-08-17 22:00:37 +05:30
Gitlab::HealthChecks::DbCheck,
2017-09-10 17:25:29 +05:30
Gitlab::HealthChecks::Redis::RedisCheck,
Gitlab::HealthChecks::Redis::CacheCheck,
Gitlab::HealthChecks::Redis::QueuesCheck,
Gitlab::HealthChecks::Redis::SharedStateCheck,
2021-09-04 01:27:46 +05:30
Gitlab::HealthChecks::Redis::TraceChunksCheck,
2021-11-18 22:05:49 +05:30
Gitlab::HealthChecks::Redis::RateLimitingCheck,
Gitlab::HealthChecks::Redis::SessionsCheck,
2018-03-17 18:26:18 +05:30
Gitlab::HealthChecks::GitalyCheck
2017-08-17 22:00:37 +05:30
].freeze
def readiness
2019-12-26 22:10:19 +05:30
# readiness check is a collection of application-level checks
# and optionally all service checks
render_checks(params[:all] ? ALL_CHECKS : CHECKS)
2017-08-17 22:00:37 +05:30
end
def liveness
2019-12-21 20:55:43 +05:30
# liveness check is a collection without additional checks
render_checks
2017-08-17 22:00:37 +05:30
end
private
2019-12-26 22:10:19 +05:30
def render_checks(checks = [])
2019-12-21 20:55:43 +05:30
result = Gitlab::HealthChecks::Probes::Collection
.new(*checks)
.execute
# disable static error pages at the gitlab-workhorse level, we want to see this error response even in production
headers["X-GitLab-Custom-Error"] = 1 unless result.success?
render json: result.json, status: result.http_status
2017-08-17 22:00:37 +05:30
end
end