Commit ed05087d authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-allow-storage-mismatch-in-dev' into 'master'

Allow Geo storage mismatch in a development environment

See merge request gitlab-org/gitlab-ee!4040
parents 0c453811 d56faabd
......@@ -199,6 +199,9 @@ class GeoNodeStatus < ActiveRecord::Base
end
def shards_match?(first, second)
# Developers may want to run Geo locally using different paths
return names_match?(first, second) if Rails.env.development?
sort_by_name(first) == sort_by_name(second)
end
......@@ -206,6 +209,14 @@ class GeoNodeStatus < ActiveRecord::Base
shards.sort_by { |shard| shard['name'] }
end
def names_match?(first, second)
extract_names(first) == extract_names(second)
end
def extract_names(shards)
shards.map { |shard| shard['name'] }.sort
end
def attachments_finder
@attachments_finder ||= Geo::AttachmentRegistryFinder.new(current_node: geo_node)
end
......
......@@ -497,5 +497,17 @@ describe GeoNodeStatus, :geo do
expect(result.storage_shards_match?).to be true
end
context 'in development mode' do
before do
allow(Rails.env).to receive(:development?).and_return(true)
end
it 'returns true if keys are same but paths are different' do
data['storage_shards'].first['path'] = '/tmp/different-path'
expect(result.storage_shards_match?).to be_truthy
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