summaryrefslogtreecommitdiff
path: root/lib/gitaly/server.rb
blob: 605e93022e70ba76f87b37416238776d8dd1151b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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