diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 9b32f18527950dcc0d800ac4be2bde9afd7a42c8..6dee9a404f48b01a12f26caa4fe4bc07914caeee 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -548,43 +548,10 @@ def self.long_timeout end end - def self.storage_metadata_file_path(storage) - Gitlab::GitalyClient::StorageSettings.allow_disk_access do - File.join( - Gitlab.config.repositories.storages[storage].legacy_disk_path, GITALY_METADATA_FILENAME - ) - end - end - - def self.can_use_disk?(storage) - cached_value = MUTEX.synchronize do - @can_use_disk ||= {} - @can_use_disk[storage] - end - - return cached_value unless cached_value.nil? - - gitaly_filesystem_id = filesystem_id(storage) - direct_filesystem_id = filesystem_id_from_disk(storage) - - MUTEX.synchronize do - @can_use_disk[storage] = gitaly_filesystem_id.present? && - gitaly_filesystem_id == direct_filesystem_id - end - end - def self.filesystem_id(storage) Gitlab::GitalyClient::ServerService.new(storage).storage_info&.filesystem_id end - def self.filesystem_id_from_disk(storage) - metadata_file = File.read(storage_metadata_file_path(storage)) - metadata_hash = Gitlab::Json.parse(metadata_file) - metadata_hash['gitaly_filesystem_id'] - rescue Errno::ENOENT, Errno::EACCES, JSON::ParserError - nil - end - def self.filesystem_disk_available(storage) Gitlab::GitalyClient::ServerService.new(storage).storage_disk_statistics&.available end diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb index 3813e40fbe35881456fa9bedc792cbd1c6a23580..796fe75521ab0e8dc65415682b53759e78a71cb8 100644 --- a/spec/lib/gitlab/gitaly_client_spec.rb +++ b/spec/lib/gitlab/gitaly_client_spec.rb @@ -40,16 +40,6 @@ def stub_repos_storages(address) end end - describe '.filesystem_id_from_disk' do - it 'catches errors' do - [Errno::ENOENT, Errno::EACCES, JSON::ParserError].each do |error| - stub_file_read(described_class.storage_metadata_file_path('default'), error: error) - - expect(described_class.filesystem_id_from_disk('default')).to be_nil - end - end - end - describe '.filesystem_id' do it 'returns an empty string when the relevant storage status is not found in the response' do response = double("response") @@ -361,19 +351,6 @@ def stub_repos_storages(address) end end - describe '.can_use_disk?' do - it 'properly caches a false result' do - # spec_helper stubs this globally - allow(described_class).to receive(:can_use_disk?).and_call_original - expect(described_class).to receive(:filesystem_id).once - expect(described_class).to receive(:filesystem_id_from_disk).once - - 2.times do - described_class.can_use_disk?('unknown') - end - end - end - describe '.connection_data' do it 'returns connection data' do address = 'tcp://localhost:9876'