Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-06-26 09:29:28 +0300
committerStan Hu <stanhu@gmail.com>2016-06-30 00:04:59 +0300
commitc600cf83488398cf66b10af85ed9490fe9457bd4 (patch)
treee5d2328ece33a987235ab28ca7a51df463ffdcac /lib/gitlab/current_settings.rb
parent84113d7e725dcf6f9a3945853475f0cede957fec (diff)
Fix database migrations when Redis is not running
If Redis were not running or USE_DB were set to false, the application settings retrieval would fail completely. This change only attempts to use the cache if the system actually wants to connect to the DB and rescues any failures in talking to Redis. Closes #17557
Diffstat (limited to 'lib/gitlab/current_settings.rb')
-rw-r--r--lib/gitlab/current_settings.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 28c34429c1f..67d6be3515d 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -9,10 +9,14 @@ module Gitlab
end
def ensure_application_settings!
- settings = ::ApplicationSetting.cached
+ if connect_to_db?
+ begin
+ settings = ::ApplicationSetting.cached
+ # In case Redis isn't running or the Redis UNIX socket file is not available
+ rescue ::Redis::BaseError, ::Errno::ENOENT
+ settings = ::ApplicationSetting.last
+ end
- if !settings && connect_to_db?
- settings = ::ApplicationSetting.current
settings ||= ::ApplicationSetting.create_from_defaults unless ActiveRecord::Migrator.needs_migration?
end