summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-07-30 15:32:59 +0000
committerGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2019-07-30 16:51:11 +0000
commita62c9ac7d3d5831e1dc9972b5482b567a6180213 (patch)
tree8ee1a616cf03e7b9dc936d6fffc622e98f74286a
parent2c49010bebc6acad1db2496e5b7f0d39764f8d62 (diff)
downloadgitlab-ce-a62c9ac7d3d5831e1dc9972b5482b567a6180213.tar.gz
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 (cherry picked from commit d92a8c1a5f9b061a10140239bed44b432b28abdf) 3b76d298 Fix exception handling in Gitaly autodetection
-rw-r--r--changelogs/unreleased/sh-fix-gitaly-access-control.yml5
-rw-r--r--lib/gitlab/gitaly_client.rb2
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb10
3 files changed, 16 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-fix-gitaly-access-control.yml b/changelogs/unreleased/sh-fix-gitaly-access-control.yml
new file mode 100644
index 00000000000..bdd33f3ff45
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-gitaly-access-control.yml
@@ -0,0 +1,5 @@
+---
+title: Fix exception handling in Gitaly autodetection
+merge_request: 31285
+author:
+type: fixed
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index c98de722fe1..4783832961d 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -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
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index e1d24ae8977..e9fb6c0125c 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -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)