Commit e26bb072 authored by Brett Walker's avatar Brett Walker

remove use of a shard's path (legacy_disk_path)

parent ce902b95
......@@ -332,14 +332,7 @@ 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
def sort_by_name(shards)
shards.sort_by { |shard| shard['name'] }
names_match?(first, second)
end
def names_match?(first, second)
......
......@@ -4,26 +4,25 @@
class StorageShard
include ActiveModel::Model
attr_accessor :name, :path
attr_accessor :name
validates :name, presence: true
validates :path, presence: true
# Generates an array of StorageShard objects from the currrent storage
# configuration using the gitlab.yml array of key/value pairs:
#
# {"default"=>{"path"=>"/home/git/repositories", ...}
# {"default"=>{"gitaly_address"=>"/home/gitaly/gitaly.socket", ...}
#
# The key is the shard name, and the values are the parameters for that shard.
def self.all
Settings.repositories.storages.map do |name, params|
config = params.symbolize_keys.merge(name: name, path: params.legacy_disk_path)
config = params.symbolize_keys.merge(name: name)
config.slice!(*allowed_params)
StorageShard.new(config)
end
end
def self.allowed_params
%i(name path).freeze
%i(name).freeze
end
end
class StorageShardEntity < Grape::Entity
expose :name, :path
expose :name
end
......@@ -124,7 +124,6 @@ describe EE::API::Entities::GeoNodeStatus, :postgresql do
expect(subject[:storage_shards].count).to eq(shards.count)
expect(subject[:storage_shards].first[:name]).to eq(shards.first.name)
expect(subject[:storage_shards].first[:path]).to eq(shards.first.path)
end
end
......
......@@ -867,17 +867,5 @@ 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
......@@ -7,7 +7,6 @@ describe StorageShard do
expect(shards.count).to eq(Settings.repositories.storages.count)
expect(shards.map(&:name)).to match_array(Settings.repositories.storages.keys)
expect(shards.map(&:path)).to match_array(Settings.repositories.storages.values.map(&:legacy_disk_path))
end
end
end
require 'spec_helper'
describe StorageShardEntity, :postgresql do
let(:entity) { described_class.new(StorageShard.new, request: double) }
subject { entity.as_json }
it { is_expected.to have_key(:name) }
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