diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-24 15:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-24 15:09:24 +0300 |
commit | d081e00aa79079792b040af3323883f1f43830c5 (patch) | |
tree | 54b5d43035030bf1eb44eee8a010ef3a21ebf97c /app/models | |
parent | d6348d22dd0c78e11d56855cb5f1fb71be437901 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/reactive_caching.rb | 8 | ||||
-rw-r--r-- | app/models/environment.rb | 5 | ||||
-rw-r--r-- | app/models/merge_request.rb | 1 |
3 files changed, 11 insertions, 3 deletions
diff --git a/app/models/concerns/reactive_caching.rb b/app/models/concerns/reactive_caching.rb index d294563139c..5f30fc0c36c 100644 --- a/app/models/concerns/reactive_caching.rb +++ b/app/models/concerns/reactive_caching.rb @@ -29,7 +29,7 @@ module ReactiveCaching self.reactive_cache_lease_timeout = 2.minutes self.reactive_cache_refresh_interval = 1.minute self.reactive_cache_lifetime = 10.minutes - self.reactive_cache_hard_limit = 1.megabyte + self.reactive_cache_hard_limit = nil # this value should be set in megabytes. E.g: 1.megabyte self.reactive_cache_work_type = :default self.reactive_cache_worker_finder = ->(id, *_args) do find_by(primary_key => id) @@ -159,8 +159,12 @@ module ReactiveCaching WORK_TYPE.fetch(self.class.reactive_cache_work_type.to_sym) end + def reactive_cache_limit_enabled? + !!self.reactive_cache_hard_limit + end + def check_exceeded_reactive_cache_limit!(data) - return unless Feature.enabled?(:reactive_cache_limit) + return unless reactive_cache_limit_enabled? data_deep_size = Gitlab::Utils::DeepSize.new(data, max_size: self.class.reactive_cache_hard_limit) diff --git a/app/models/environment.rb b/app/models/environment.rb index 103d34f753d..a3b8f220f00 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -362,6 +362,11 @@ class Environment < ApplicationRecord def generate_slug self.slug = Gitlab::Slug::Environment.new(name).generate end + + # Overrides ReactiveCaching default to activate limit checking behind a FF + def reactive_cache_limit_enabled? + Feature.enabled?(:reactive_caching_limit_environment, project) + end end Environment.prepend_if_ee('EE::Environment') diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 68ff336a1bb..699f82c7e6b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -26,7 +26,6 @@ class MergeRequest < ApplicationRecord self.reactive_cache_key = ->(model) { [model.project.id, model.iid] } self.reactive_cache_refresh_interval = 10.minutes self.reactive_cache_lifetime = 10.minutes - self.reactive_cache_hard_limit = 20.megabytes SORTING_PREFERENCE_FIELD = :merge_requests_sort |