Merge branch 'sh-fix-gitaly-access-control' into 'master'
Fix exception handling in Gitaly autodetection Closes #65328 See merge request gitlab-org/gitlab-ce!31285
This commit is contained in:
commit
d92a8c1a5f
3 changed files with 16 additions and 1 deletions
5
changelogs/unreleased/sh-fix-gitaly-access-control.yml
Normal file
5
changelogs/unreleased/sh-fix-gitaly-access-control.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix exception handling in Gitaly autodetection
|
||||
merge_request: 31285
|
||||
author:
|
||||
type: fixed
|
|
@ -413,7 +413,7 @@ module Gitlab
|
|||
metadata_file = File.read(storage_metadata_file_path(storage))
|
||||
metadata_hash = JSON.parse(metadata_file)
|
||||
metadata_hash['gitaly_filesystem_id']
|
||||
rescue Errno::ENOENT, Errno::ACCESS, JSON::ParserError
|
||||
rescue Errno::ENOENT, Errno::EACCES, JSON::ParserError
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -17,6 +17,16 @@ describe Gitlab::GitalyClient do
|
|||
})
|
||||
end
|
||||
|
||||
describe '.filesystem_id_from_disk' do
|
||||
it 'catches errors' do
|
||||
[Errno::ENOENT, Errno::EACCES, JSON::ParserError].each do |error|
|
||||
allow(File).to receive(:read).with(described_class.storage_metadata_file_path('default')).and_raise(error)
|
||||
|
||||
expect(described_class.filesystem_id_from_disk('default')).to be_nil
|
||||
end
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue