diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/health_checks | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/health_checks')
-rw-r--r-- | lib/gitlab/health_checks/metric.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/health_checks/probes/status.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/cache_check.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/queues_check.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/rate_limiting_check.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/redis_abstract_check.rb | 41 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/redis_check.rb | 20 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/sessions_check.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/shared_state_check.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/health_checks/redis/trace_chunks_check.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/health_checks/result.rb | 3 |
11 files changed, 69 insertions, 157 deletions
diff --git a/lib/gitlab/health_checks/metric.rb b/lib/gitlab/health_checks/metric.rb index b697cb0d027..c1e437831d7 100644 --- a/lib/gitlab/health_checks/metric.rb +++ b/lib/gitlab/health_checks/metric.rb @@ -1,3 +1,4 @@ +# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab @@ -5,3 +6,5 @@ module Gitlab Metric = Struct.new(:name, :value, :labels) end end + +# rubocop:enable Naming/FileName diff --git a/lib/gitlab/health_checks/probes/status.rb b/lib/gitlab/health_checks/probes/status.rb index 192e9366001..1c59f18ff7d 100644 --- a/lib/gitlab/health_checks/probes/status.rb +++ b/lib/gitlab/health_checks/probes/status.rb @@ -1,3 +1,4 @@ +# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab @@ -12,3 +13,5 @@ module Gitlab end end end + +# rubocop:enable Naming/FileName diff --git a/lib/gitlab/health_checks/redis/cache_check.rb b/lib/gitlab/health_checks/redis/cache_check.rb index 0c8fe83893b..bd843bdaac4 100644 --- a/lib/gitlab/health_checks/redis/cache_check.rb +++ b/lib/gitlab/health_checks/redis/cache_check.rb @@ -4,31 +4,7 @@ module Gitlab module HealthChecks module Redis class CacheCheck - extend SimpleAbstractCheck - - class << self - def check_up - check - end - - private - - def metric_prefix - 'redis_cache_ping' - end - - def successful?(result) - result == 'PONG' - end - - # rubocop: disable CodeReuse/ActiveRecord - def check - catch_timeout 10.seconds do - Gitlab::Redis::Cache.with(&:ping) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end + extend RedisAbstractCheck end end end diff --git a/lib/gitlab/health_checks/redis/queues_check.rb b/lib/gitlab/health_checks/redis/queues_check.rb index b1e33b9f459..fb92db937dc 100644 --- a/lib/gitlab/health_checks/redis/queues_check.rb +++ b/lib/gitlab/health_checks/redis/queues_check.rb @@ -4,31 +4,7 @@ module Gitlab module HealthChecks module Redis class QueuesCheck - extend SimpleAbstractCheck - - class << self - def check_up - check - end - - private - - def metric_prefix - 'redis_queues_ping' - end - - def successful?(result) - result == 'PONG' - end - - # rubocop: disable CodeReuse/ActiveRecord - def check - catch_timeout 10.seconds do - Gitlab::Redis::Queues.with(&:ping) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end + extend RedisAbstractCheck end end end diff --git a/lib/gitlab/health_checks/redis/rate_limiting_check.rb b/lib/gitlab/health_checks/redis/rate_limiting_check.rb index 67c14e26361..0e9d94f7dff 100644 --- a/lib/gitlab/health_checks/redis/rate_limiting_check.rb +++ b/lib/gitlab/health_checks/redis/rate_limiting_check.rb @@ -4,31 +4,7 @@ module Gitlab module HealthChecks module Redis class RateLimitingCheck - extend SimpleAbstractCheck - - class << self - def check_up - check - end - - private - - def metric_prefix - 'redis_rate_limiting_ping' - end - - def successful?(result) - result == 'PONG' - end - - # rubocop: disable CodeReuse/ActiveRecord - def check - catch_timeout 10.seconds do - Gitlab::Redis::RateLimiting.with(&:ping) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end + extend RedisAbstractCheck end end end diff --git a/lib/gitlab/health_checks/redis/redis_abstract_check.rb b/lib/gitlab/health_checks/redis/redis_abstract_check.rb new file mode 100644 index 00000000000..ecad4b06ea9 --- /dev/null +++ b/lib/gitlab/health_checks/redis/redis_abstract_check.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Gitlab + module HealthChecks + module Redis + module RedisAbstractCheck + include SimpleAbstractCheck + + def check_up + successful?(check) + end + + private + + def redis_instance_class_name + Gitlab::Redis.const_get(redis_instance_name.camelize, false) + end + + def metric_prefix + "redis_#{redis_instance_name}_ping" + end + + def redis_instance_name + name.sub(/_check$/, '') + end + + def successful?(result) + result == 'PONG' + end + + # rubocop: disable CodeReuse/ActiveRecord + def check + catch_timeout 10.seconds do + redis_instance_class_name.with(&:ping) + end + end + # rubocop: enable CodeReuse/ActiveRecord + end + end + end +end diff --git a/lib/gitlab/health_checks/redis/redis_check.rb b/lib/gitlab/health_checks/redis/redis_check.rb index 25879c18f84..c793a939abd 100644 --- a/lib/gitlab/health_checks/redis/redis_check.rb +++ b/lib/gitlab/health_checks/redis/redis_check.rb @@ -14,16 +14,22 @@ module Gitlab end def successful?(result) - result == 'PONG' + result == true end def check - ::Gitlab::HealthChecks::Redis::CacheCheck.check_up && - ::Gitlab::HealthChecks::Redis::QueuesCheck.check_up && - ::Gitlab::HealthChecks::Redis::SharedStateCheck.check_up && - ::Gitlab::HealthChecks::Redis::TraceChunksCheck.check_up && - ::Gitlab::HealthChecks::Redis::RateLimitingCheck.check_up && - ::Gitlab::HealthChecks::Redis::SessionsCheck.check_up + redis_health_checks.all?(&:check_up) + end + + def redis_health_checks + [ + Gitlab::HealthChecks::Redis::CacheCheck, + Gitlab::HealthChecks::Redis::QueuesCheck, + Gitlab::HealthChecks::Redis::SharedStateCheck, + Gitlab::HealthChecks::Redis::TraceChunksCheck, + Gitlab::HealthChecks::Redis::RateLimitingCheck, + Gitlab::HealthChecks::Redis::SessionsCheck + ] end end end diff --git a/lib/gitlab/health_checks/redis/sessions_check.rb b/lib/gitlab/health_checks/redis/sessions_check.rb index a0c5e177b4e..90a4c868f40 100644 --- a/lib/gitlab/health_checks/redis/sessions_check.rb +++ b/lib/gitlab/health_checks/redis/sessions_check.rb @@ -4,31 +4,7 @@ module Gitlab module HealthChecks module Redis class SessionsCheck - extend SimpleAbstractCheck - - class << self - def check_up - check - end - - private - - def metric_prefix - 'redis_sessions_ping' - end - - def successful?(result) - result == 'PONG' - end - - # rubocop: disable CodeReuse/ActiveRecord - def check - catch_timeout 10.seconds do - Gitlab::Redis::Sessions.with(&:ping) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end + extend RedisAbstractCheck end end end diff --git a/lib/gitlab/health_checks/redis/shared_state_check.rb b/lib/gitlab/health_checks/redis/shared_state_check.rb index 285ac271929..80f91784b8c 100644 --- a/lib/gitlab/health_checks/redis/shared_state_check.rb +++ b/lib/gitlab/health_checks/redis/shared_state_check.rb @@ -4,31 +4,7 @@ module Gitlab module HealthChecks module Redis class SharedStateCheck - extend SimpleAbstractCheck - - class << self - def check_up - check - end - - private - - def metric_prefix - 'redis_shared_state_ping' - end - - def successful?(result) - result == 'PONG' - end - - # rubocop: disable CodeReuse/ActiveRecord - def check - catch_timeout 10.seconds do - Gitlab::Redis::SharedState.with(&:ping) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end + extend RedisAbstractCheck end end end diff --git a/lib/gitlab/health_checks/redis/trace_chunks_check.rb b/lib/gitlab/health_checks/redis/trace_chunks_check.rb index cf9fa700b0a..9a89a1ce51d 100644 --- a/lib/gitlab/health_checks/redis/trace_chunks_check.rb +++ b/lib/gitlab/health_checks/redis/trace_chunks_check.rb @@ -4,31 +4,7 @@ module Gitlab module HealthChecks module Redis class TraceChunksCheck - extend SimpleAbstractCheck - - class << self - def check_up - check - end - - private - - def metric_prefix - 'redis_trace_chunks_ping' - end - - def successful?(result) - result == 'PONG' - end - - # rubocop: disable CodeReuse/ActiveRecord - def check - catch_timeout 10.seconds do - Gitlab::Redis::TraceChunks.with(&:ping) - end - end - # rubocop: enable CodeReuse/ActiveRecord - end + extend RedisAbstractCheck end end end diff --git a/lib/gitlab/health_checks/result.rb b/lib/gitlab/health_checks/result.rb index 38a36100ec7..cbb847d2af2 100644 --- a/lib/gitlab/health_checks/result.rb +++ b/lib/gitlab/health_checks/result.rb @@ -1,3 +1,4 @@ +# rubocop:disable Naming/FileName # frozen_string_literal: true module Gitlab @@ -13,3 +14,5 @@ module Gitlab end end end + +# rubocop:enable Naming/FileName |