Commit d56faabd authored by Stan Hu's avatar Stan Hu

Allow Geo storage mismatch in a development environment

If you want to run a Geo primary and secondary locally, your storage
configuration should have the same names but different paths. This change
loosens the check to ensure the names are the same.
parent 4180b3de
...@@ -199,6 +199,9 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -199,6 +199,9 @@ class GeoNodeStatus < ActiveRecord::Base
end end
def shards_match?(first, second) 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) sort_by_name(first) == sort_by_name(second)
end end
...@@ -206,6 +209,14 @@ class GeoNodeStatus < ActiveRecord::Base ...@@ -206,6 +209,14 @@ class GeoNodeStatus < ActiveRecord::Base
shards.sort_by { |shard| shard['name'] } shards.sort_by { |shard| shard['name'] }
end 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 def attachments_finder
@attachments_finder ||= Geo::AttachmentRegistryFinder.new(current_node: geo_node) @attachments_finder ||= Geo::AttachmentRegistryFinder.new(current_node: geo_node)
end end
......
...@@ -497,5 +497,17 @@ describe GeoNodeStatus, :geo do ...@@ -497,5 +497,17 @@ describe GeoNodeStatus, :geo do
expect(result.storage_shards_match?).to be true expect(result.storage_shards_match?).to be true
end 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
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