Commit e8492290 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'jc-fix-auto-rugged-detection' into 'master'

Handle when server info doesn't have the storage in question

See merge request gitlab-org/gitlab-ce!32023
parents 15ea6147 ebbd2aeb
......@@ -406,7 +406,8 @@ module Gitlab
def self.filesystem_id(storage)
response = Gitlab::GitalyClient::ServerService.new(storage).info
storage_status = response.storage_statuses.find { |status| status.storage_name == storage }
storage_status.filesystem_id
storage_status&.filesystem_id
end
def self.filesystem_id_from_disk(storage)
......
......@@ -27,6 +27,16 @@ describe Gitlab::GitalyClient do
end
end
describe '.filesystem_id' do
it 'returns an empty string when the storage is not found in the response' do
response = double("response")
allow(response).to receive(:storage_statuses).and_return([])
allow_any_instance_of(Gitlab::GitalyClient::ServerService).to receive(:info).and_return(response)
expect(described_class.filesystem_id('default')).to eq(nil)
end
end
describe '.stub_class' do
it 'returns the gRPC health check stub' do
expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub)
......
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