Commit 3b9a9109 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets Committed by Robert Speicher

Merge branch 'expire-application-settings-startup' of https://gitlab.com/stanhu/gitlab-ce

parent 0bbf7563
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.2.2 v 8.2.2
- Ensure cached application settings are refreshed at startup (Stan Hu)
- Fix: Raw private snippets access workflow - Fix: Raw private snippets access workflow
- Prevent "413 Request entity too large" errors when pushing large files with LFS - Prevent "413 Request entity too large" errors when pushing large files with LFS
......
...@@ -73,15 +73,23 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -73,15 +73,23 @@ class ApplicationSetting < ActiveRecord::Base
end end
after_commit do after_commit do
Rails.cache.write('application_setting.last', self) Rails.cache.write(cache_key, self)
end end
def self.current def self.current
Rails.cache.fetch('application_setting.last') do Rails.cache.fetch(cache_key) do
ApplicationSetting.last ApplicationSetting.last
end end
end end
def self.expire
Rails.cache.delete(cache_key)
end
def self.cache_key
'application_setting.last'
end
def self.create_from_defaults def self.create_from_defaults
create( create(
default_projects_limit: Settings.gitlab['default_projects_limit'], default_projects_limit: Settings.gitlab['default_projects_limit'],
......
...@@ -14,11 +14,15 @@ module Ci ...@@ -14,11 +14,15 @@ module Ci
extend Ci::Model extend Ci::Model
after_commit do after_commit do
Rails.cache.write('ci_application_setting.last', self) Rails.cache.write(cache_key, self)
end
def self.expire
Rails.cache.delete(cache_key)
end end
def self.current def self.current
Rails.cache.fetch('ci_application_setting.last') do Rails.cache.fetch(cache_key) do
Ci::ApplicationSetting.last Ci::ApplicationSetting.last
end end
end end
...@@ -29,5 +33,9 @@ module Ci ...@@ -29,5 +33,9 @@ module Ci
add_pusher: Settings.gitlab_ci['add_pusher'], add_pusher: Settings.gitlab_ci['add_pusher'],
) )
end end
def self.cache_key
'ci_application_setting.last'
end
end end
end end
...@@ -293,3 +293,12 @@ if Rails.env.test? ...@@ -293,3 +293,12 @@ if Rails.env.test?
Settings.gitlab['default_can_create_group'] = true Settings.gitlab['default_can_create_group'] = true
Settings.gitlab['default_can_create_team'] = false Settings.gitlab['default_can_create_team'] = false
end end
# Force a refresh of application settings at startup
begin
ApplicationSetting.expire
Ci::ApplicationSetting.expire
rescue
# Gracefully handle when Redis is not available. For example,
# omnibus may fail here during assets:precompile.
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment