summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-07-19 18:23:27 +0000
committer🤖 GitLab Bot 🤖 <gitlab-bot@gitlab.com>2019-07-19 18:24:49 +0000
commitca2ec64191e790ecc09ed8838d3aa1d8963fd525 (patch)
tree6e65f46d64bc8c005a25a3b60b4b7eaa1fd2bf9c
parent5ead2f7abac08d71d12199386cad1eea8fb8725a (diff)
downloadgitlab-ce-12-1-auto-deploy-20190718.tar.gz
Merge branch 'sh-fix-gitaly-server-info-cache' into 'master'12-1-auto-deploy-20190718
Fix Gitaly auto-detection caching Closes #64802 See merge request gitlab-org/gitlab-ce!30954 (cherry picked from commit eb3f465e75ee1fc5ef582e9f01f921626d7cf5cc) ec5ceae6 Fix Gitaly auto-detection caching
-rw-r--r--changelogs/unreleased/sh-fix-gitaly-server-info-cache.yml5
-rw-r--r--lib/gitlab/gitaly_client.rb2
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb13
3 files changed, 19 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-fix-gitaly-server-info-cache.yml b/changelogs/unreleased/sh-fix-gitaly-server-info-cache.yml
new file mode 100644
index 00000000000..ef8f6e25856
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-gitaly-server-info-cache.yml
@@ -0,0 +1,5 @@
+---
+title: Fix Gitaly auto-detection caching
+merge_request: 30954
+author:
+type: performance
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index e7319a7b7f0..c98de722fe1 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -392,7 +392,7 @@ module Gitlab
@can_use_disk[storage]
end
- return cached_value if cached_value.present?
+ return cached_value unless cached_value.nil?
gitaly_filesystem_id = filesystem_id(storage)
direct_filesystem_id = filesystem_id_from_disk(storage)
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index b8debee3b58..e1d24ae8977 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -119,6 +119,19 @@ describe Gitlab::GitalyClient do
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'