diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-06-20 10:21:59 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-06-27 08:56:19 +0200 |
commit | 65840591cd8bdc81281357d062728be9309c5597 (patch) | |
tree | 2a6330c16835961a59cfc3e64ac87346339fa544 /lib/gitaly | |
parent | 292cf668905a55e7b305c67b314cb039d2681a54 (diff) | |
download | gitlab-ce-65840591cd8bdc81281357d062728be9309c5597.tar.gz |
Gitaly metrics check for read/writeability
Prior to this change, health checks checked for writeability of the NFS
shards. Given we're moving away from that, this patch extends the checks
for Gitaly to check for read and writeability.
Potentially some dashboards will break, as over time these metrics will
no longer appear as Prometheus doesn't get the data anymore.
Observability in the circuit breaker will be reduced, but its not
expected to be turned on and the circuit breaker is being removed soon
too.
Closes https://gitlab.com/gitlab-org/gitaly/issues/1218
Diffstat (limited to 'lib/gitaly')
-rw-r--r-- | lib/gitaly/server.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/gitaly/server.rb b/lib/gitaly/server.rb index 605e93022e7..2760211fee8 100644 --- a/lib/gitaly/server.rb +++ b/lib/gitaly/server.rb @@ -22,6 +22,18 @@ module Gitaly server_version == Gitlab::GitalyClient.expected_server_version end + def read_writeable? + readable? && writeable? + end + + def readable? + storage_status&.readable + end + + def writeable? + storage_status&.writeable + end + def address Gitlab::GitalyClient.address(@storage) rescue RuntimeError => e @@ -30,13 +42,17 @@ module Gitaly private + def storage_status + @storage_status ||= info.storage_statuses.find { |s| s.storage_name == storage } + end + def info @info ||= begin Gitlab::GitalyClient::ServerService.new(@storage).info rescue GRPC::Unavailable, GRPC::GRPC::DeadlineExceeded # This will show the server as being out of date - Gitaly::ServerInfoResponse.new(git_version: '', server_version: '') + Gitaly::ServerInfoResponse.new(git_version: '', server_version: '', storage_statuses: []) end end end |