Commit e5ca52a7 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ac-fix-gitaly-uptodate-autodeploy' into 'master'

Fix gitaly version check in case of autodeploy

See merge request gitlab-org/gitlab!20618
parents abe86568 6ba68036
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module Gitaly module Gitaly
class Server class Server
SHA_VERSION_REGEX = /\A\d+\.\d+\.\d+-\d+-g([a-f0-9]{8})\z/.freeze
class << self class << self
def all def all
Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) } Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) }
...@@ -30,9 +32,10 @@ module Gitaly ...@@ -30,9 +32,10 @@ module Gitaly
info.git_version info.git_version
end end
def up_to_date? def expected_version?
server_version == Gitlab::GitalyClient.expected_server_version server_version == Gitlab::GitalyClient.expected_server_version || matches_sha?
end end
alias_method :up_to_date?, :expected_version?
def read_writeable? def read_writeable?
readable? && writeable? readable? && writeable?
...@@ -62,6 +65,13 @@ module Gitaly ...@@ -62,6 +65,13 @@ module Gitaly
@storage_status ||= info.storage_statuses.find { |s| s.storage_name == storage } @storage_status ||= info.storage_statuses.find { |s| s.storage_name == storage }
end end
def matches_sha?
match = server_version.match(SHA_VERSION_REGEX)
return false unless match
Gitlab::GitalyClient.expected_server_version.start_with?(match[1])
end
def info def info
@info ||= @info ||=
begin begin
......
...@@ -65,4 +65,26 @@ describe Gitaly::Server do ...@@ -65,4 +65,26 @@ describe Gitaly::Server do
end end
end end
end end
describe '#expected_version?' do
using RSpec::Parameterized::TableSyntax
where(:expected_version, :server_version, :result) do
'1.1.1' | '1.1.1' | true
'1.1.2' | '1.1.1' | false
'1.73.0' | '1.73.0-18-gf756ebe2' | false
'594c3ea3e0e5540e5915bd1c49713a0381459dd6' | '1.55.6-45-g594c3ea3' | true
'594c3ea3e0e5540e5915bd1c49713a0381459dd6' | '1.55.6-46-gabc123ff' | false
'594c3ea3e0e5540e5915bd1c49713a0381459dd6' | '1.55.6' | false
end
with_them do
it do
allow(Gitlab::GitalyClient).to receive(:expected_server_version).and_return(expected_version)
allow(server).to receive(:server_version).and_return(server_version)
expect(server.expected_version?).to eq(result)
end
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