summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-11-12 16:00:21 -0800
committerStan Hu <stanhu@gmail.com>2016-11-12 16:00:21 -0800
commit5a65d9d53bd24574c833dd4fba4b8ae44f71b822 (patch)
treee27d68a0285db83a4f0fb097853b1a7ec479a53e
parent6480259744476ec7fdcb1464ed709f9833f29d95 (diff)
downloadgitlab-ce-5a65d9d53bd24574c833dd4fba4b8ae44f71b822.tar.gz
Only turn on Sidekiq throttling if application settings existssh-fix-sidekiq-throttling-init
If the database has not been migrated properly, the initializer for Sidekiq will fail to start and cause the whole Rails server to crash. This change checks the existence for the column and allows Rails to start even if the setting has not been added as a database column. Closes #24452
-rw-r--r--app/models/application_setting.rb10
-rw-r--r--lib/gitlab/current_settings.rb2
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index d1e1b45ab43..bf463a3b6bb 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -203,6 +203,10 @@ class ApplicationSetting < ActiveRecord::Base
ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url)
end
+ def sidekiq_throttling_column_exists?
+ ActiveRecord::Base.connection.column_exists?(:application_settings, :sidekiq_throttling_enabled)
+ end
+
def domain_whitelist_raw
self.domain_whitelist.join("\n") unless self.domain_whitelist.nil?
end
@@ -256,6 +260,12 @@ class ApplicationSetting < ActiveRecord::Base
ensure_health_check_access_token!
end
+ def sidekiq_throttling_enabled?
+ return false unless sidekiq_throttling_column_exists?
+
+ sidekiq_throttling_enabled
+ end
+
private
def check_repository_storages
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 3a651ef318a..c6bb8f9c8ed 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -24,7 +24,7 @@ module Gitlab
end
def sidekiq_throttling_enabled?
- current_application_settings.sidekiq_throttling_enabled
+ current_application_settings.sidekiq_throttling_enabled?
end
def fake_application_settings