Welcome to mirror list, hosted at ThFree Co, Russian Federation.

health_controller.rb « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 071378f266e1fb0702c255f0c058f1b263f4d7ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

class HealthController < ActionController::Base
  protect_from_forgery with: :exception, prepend: true
  include RequiresWhitelistedMonitoringClient

  CHECKS = [
    Gitlab::HealthChecks::MasterCheck
  ].freeze

  ALL_CHECKS = [
    *CHECKS,
    Gitlab::HealthChecks::DbCheck,
    Gitlab::HealthChecks::Redis::RedisCheck,
    Gitlab::HealthChecks::Redis::CacheCheck,
    Gitlab::HealthChecks::Redis::QueuesCheck,
    Gitlab::HealthChecks::Redis::SharedStateCheck,
    Gitlab::HealthChecks::Redis::TraceChunksCheck,
    Gitlab::HealthChecks::Redis::RateLimitingCheck,
    Gitlab::HealthChecks::Redis::SessionsCheck,
    Gitlab::HealthChecks::GitalyCheck
  ].freeze

  def readiness
    # readiness check is a collection of application-level checks
    # and optionally all service checks
    render_checks(params[:all] ? ALL_CHECKS : CHECKS)
  end

  def liveness
    # liveness check is a collection without additional checks
    render_checks
  end

  private

  def render_checks(checks = [])
    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
  end
end