Commit f40f0c30 authored by Toon Claes's avatar Toon Claes

Refactor fetching healthy shards with Gitlab::HealthChecks::GitalyCheck

There is only 1 `HEALTHY_SHARD_CHECKS` used:
Gitlab::HealthChecks::GitalyCheck

So we can simplify code to get the list of healthy shard names.
parent 041a8ae2
...@@ -2,10 +2,6 @@ module EachShardWorker ...@@ -2,10 +2,6 @@ module EachShardWorker
extend ActiveSupport::Concern extend ActiveSupport::Concern
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
HEALTHY_SHARD_CHECKS = [
Gitlab::HealthChecks::GitalyCheck
].freeze
def each_eligible_shard def each_eligible_shard
Gitlab::ShardHealthCache.update(eligible_shard_names) Gitlab::ShardHealthCache.update(eligible_shard_names)
...@@ -21,18 +17,15 @@ module EachShardWorker ...@@ -21,18 +17,15 @@ module EachShardWorker
def healthy_shard_names def healthy_shard_names
strong_memoize(:healthy_shard_names) do strong_memoize(:healthy_shard_names) do
# For now, we need to perform both Gitaly and direct filesystem checks to ensure healthy_ready_shards.map { |result| result.labels[:shard] }
# the shard is healthy. We take the intersection of the successful checks
# as the healthy shards.
healthy_ready_shards.map { |result| result.labels[:shard] }.compact.uniq
end end
end end
def healthy_ready_shards def healthy_ready_shards
ready_shards.map { |result| result.select(&:success) }.inject(:&) ready_shards.select(&:success)
end end
def ready_shards def ready_shards
HEALTHY_SHARD_CHECKS.map(&:readiness) Gitlab::HealthChecks::GitalyCheck.readiness
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment