diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-31 11:31:29 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-31 11:31:29 +0000 |
commit | 5d8bb33d48826abc7cd348a7c151c5b6985f0ade (patch) | |
tree | 24fdd6e911e931888c7786302016e603543c68f7 /lib | |
parent | 4251c6565fa18ecd64befe3a2561df30d48d1846 (diff) | |
parent | 94a3dbca33634dd4f6a1de8b14cd2a4f0a9a0abc (diff) | |
download | gitlab-ce-5d8bb33d48826abc7cd348a7c151c5b6985f0ade.tar.gz |
Merge branch 'zj-gitaly-server-info' into 'master'
Gitaly Server info for admin panel
See merge request gitlab-org/gitlab-ce!16794
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitaly/server.rb | 43 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/server_service.rb | 16 |
2 files changed, 59 insertions, 0 deletions
diff --git a/lib/gitaly/server.rb b/lib/gitaly/server.rb new file mode 100644 index 00000000000..605e93022e7 --- /dev/null +++ b/lib/gitaly/server.rb @@ -0,0 +1,43 @@ +module Gitaly + class Server + def self.all + Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) } + end + + attr_reader :storage + + def initialize(storage) + @storage = storage + end + + def server_version + info.server_version + end + + def git_binary_version + info.git_version + end + + def up_to_date? + server_version == Gitlab::GitalyClient.expected_server_version + end + + def address + Gitlab::GitalyClient.address(@storage) + rescue RuntimeError => e + "Error getting the address: #{e.message}" + end + + private + + 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: '') + end + end + end +end diff --git a/lib/gitlab/gitaly_client/server_service.rb b/lib/gitlab/gitaly_client/server_service.rb new file mode 100644 index 00000000000..2e1076d1f66 --- /dev/null +++ b/lib/gitlab/gitaly_client/server_service.rb @@ -0,0 +1,16 @@ +module Gitlab + module GitalyClient + # Meant for extraction of server data, and later maybe to perform misc task + # + # Not meant for connection logic, look in Gitlab::GitalyClient + class ServerService + def initialize(storage) + @storage = storage + end + + def info + GitalyClient.call(@storage, :server_service, :server_info, Gitaly::ServerInfoRequest.new) + end + end + end +end |