diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/feature/gitaly.rb | 22 | ||||
| -rw-r--r-- | lib/gitlab/gitaly_client.rb | 1 | ||||
| -rw-r--r-- | lib/gitlab/gitaly_client/storage_settings.rb | 2 |
3 files changed, 15 insertions, 10 deletions
diff --git a/lib/feature/gitaly.rb b/lib/feature/gitaly.rb index 33868e49f14..d7a8f8a0b9e 100644 --- a/lib/feature/gitaly.rb +++ b/lib/feature/gitaly.rb @@ -1,24 +1,30 @@ +# frozen_string_literal: true + +require 'set' + class Feature class Gitaly + # Server feature flags should use '_' to separate words. + # CATFILE_CACHE sets an incorrect example CATFILE_CACHE = 'catfile-cache'.freeze - # Server feature flags should use '_' to separate words. SERVER_FEATURE_FLAGS = [CATFILE_CACHE].freeze + DEFAULT_ON_FLAGS = Set.new([CATFILE_CACHE]).freeze class << self def enabled?(feature_flag) - Feature::FlipperFeature.table_exists? && Feature.enabled?("gitaly_#{feature_flag}") + return false unless Feature::FlipperFeature.table_exists? + + default_on = DEFAULT_ON_FLAGS.include?(feature_flag) + Feature.enabled?("gitaly_#{feature_flag}", default_enabled: default_on) rescue ActiveRecord::NoDatabaseError false end def server_feature_flags - @server_feature_flags ||= - begin - SERVER_FEATURE_FLAGS.map do |f| - ["gitaly-feature-#{f.tr('_', '-')}", enabled?(f).to_s] - end.to_h - end + SERVER_FEATURE_FLAGS.map do |f| + ["gitaly-feature-#{f.tr('_', '-')}", enabled?(f).to_s] + end.to_h end end end diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index f3b0e65400b..47976389af6 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -240,7 +240,6 @@ module Gitlab Gitlab::SafeRequestStore[:gitaly_session_id] ||= SecureRandom.uuid end - def self.token(storage) params = Gitlab.config.repositories.storages[storage] raise "storage not found: #{storage.inspect}" if params.nil? diff --git a/lib/gitlab/gitaly_client/storage_settings.rb b/lib/gitlab/gitaly_client/storage_settings.rb index 78ef6bfc0ec..7d1206e551b 100644 --- a/lib/gitlab/gitaly_client/storage_settings.rb +++ b/lib/gitlab/gitaly_client/storage_settings.rb @@ -34,7 +34,7 @@ module Gitlab def self.disk_access_denied? return false if rugged_enabled? - !temporarily_allowed?(ALLOW_KEY) && GitalyClient.feature_enabled?(DISK_ACCESS_DENIED_FLAG) + !temporarily_allowed?(ALLOW_KEY) && Feature::Gitaly.enabled?(DISK_ACCESS_DENIED_FLAG) rescue false # Err on the side of caution, don't break gitlab for people end |
