2018-01-30 05:11:47 -05:00
|
|
|
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
|
|
|
|
|
2018-06-20 04:21:59 -04:00
|
|
|
def read_writeable?
|
|
|
|
readable? && writeable?
|
|
|
|
end
|
|
|
|
|
|
|
|
def readable?
|
|
|
|
storage_status&.readable
|
|
|
|
end
|
|
|
|
|
|
|
|
def writeable?
|
|
|
|
storage_status&.writeable
|
|
|
|
end
|
|
|
|
|
2018-01-30 05:11:47 -05:00
|
|
|
def address
|
|
|
|
Gitlab::GitalyClient.address(@storage)
|
|
|
|
rescue RuntimeError => e
|
|
|
|
"Error getting the address: #{e.message}"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-06-20 04:21:59 -04:00
|
|
|
def storage_status
|
|
|
|
@storage_status ||= info.storage_statuses.find { |s| s.storage_name == storage }
|
|
|
|
end
|
|
|
|
|
2018-01-30 05:11:47 -05:00
|
|
|
def info
|
|
|
|
@info ||=
|
|
|
|
begin
|
|
|
|
Gitlab::GitalyClient::ServerService.new(@storage).info
|
2018-07-11 06:52:48 -04:00
|
|
|
rescue GRPC::Unavailable, GRPC::DeadlineExceeded
|
2018-01-30 05:11:47 -05:00
|
|
|
# This will show the server as being out of date
|
2018-06-20 04:21:59 -04:00
|
|
|
Gitaly::ServerInfoResponse.new(git_version: '', server_version: '', storage_statuses: [])
|
2018-01-30 05:11:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|