diff options
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/1_settings.rb | 18 | ||||
-rw-r--r-- | config/initializers/fog_core_patch.rb | 52 | ||||
-rw-r--r-- | config/initializers/graphql.rb | 2 | ||||
-rw-r--r-- | config/initializers/sidekiq.rb | 5 |
4 files changed, 75 insertions, 2 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 1344b3cb1f6..03800f3d9d2 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -40,6 +40,24 @@ if Settings.ldap['enabled'] || Rails.env.test? # Since GitLab 10.0, verify_certificates defaults to true for security. server['verify_certificates'] = true if server['verify_certificates'].nil? + # Expose ability to set `tls_options` directly. Deprecate `ca_file` and + # `ssl_version` in favor of `tls_options` hash option. + server['tls_options'] ||= {} + + if server['ssl_version'] || server['ca_file'] + Rails.logger.warn 'DEPRECATED: LDAP options `ssl_version` and `ca_file` should be nested within `tls_options`' + end + + if server['ssl_version'] + server['tls_options']['ssl_version'] ||= server['ssl_version'] + server.delete('ssl_version') + end + + if server['ca_file'] + server['tls_options']['ca_file'] ||= server['ca_file'] + server.delete('ca_file') + end + Settings.ldap['servers'][key] = server end end diff --git a/config/initializers/fog_core_patch.rb b/config/initializers/fog_core_patch.rb new file mode 100644 index 00000000000..d3d02216d45 --- /dev/null +++ b/config/initializers/fog_core_patch.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +# +# fog-core v2 changed the namespace format: +# +# Old: Fog::<service>::<provider> (e.g. Fog::Storage::AWS). +# New: Fog::<provider>::<service> (e.g. Fog::AWS::Storage) +# +# To preserve backwards compatibility, fog-core v2.1.0 tries to load the +# old schema first, but falls back to the older version if that +# fails. This creates misleading warnings with fog-aws. See +# https://github.com/fog/fog-aws/issues/504#issuecomment-468067991 for +# more details. +# +# fog-core v2.1.2 reverses the load order +# (https://github.com/fog/fog-core/pull/229), which works for fog-aws +# but causes a stream of deprecation warnings for fog-google. +# fog-google locked the dependency on fog-core v2.1.0 as a result +# (https://github.com/fog/fog-google/issues/421) until the new namespace +# is supported. +# +# Since we currently have some Fog gems that have not been updated, this +# monkey patch makes a smarter decision about which namespace to try +# first. This squelches a significant number of warning messages. +# +# Since this patch is mostly cosmetic, it can be removed safely at any +# time, but it's probably best to wait until the following issues are +# closed: +# +# fog-google: https://github.com/fog/fog-google/issues/421 +# fog-rackspace: https://github.com/fog/fog-rackspace/issues/29 +# fog-aliyun: https://github.com/fog/fog-aliyun/issues/23 +module Fog + module ServicesMixin + # Gems that have not yet updated with the new fog-core namespace + LEGACY_FOG_PROVIDERS = %w(google rackspace aliyun).freeze + + def service_provider_constant(service_name, provider_name) + args = service_provider_search_args(service_name, provider_name) + Fog.const_get(args.first).const_get(*const_get_args(args.second)) + rescue NameError # Try to find the constant from in an alternate location + Fog.const_get(args.second).const_get(*const_get_args(args.first)) + end + + def service_provider_search_args(service_name, provider_name) + if LEGACY_FOG_PROVIDERS.include?(provider_name.downcase) + [service_name, provider_name] + else + [provider_name, service_name] + end + end + end +end diff --git a/config/initializers/graphql.rb b/config/initializers/graphql.rb index 1ed93019329..e653556231d 100644 --- a/config/initializers/graphql.rb +++ b/config/initializers/graphql.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true GraphQL::Field.accepts_definitions(authorize: GraphQL::Define.assign_metadata_key(:authorize)) -Types::BaseField.accepts_definition(:authorize) +GraphQL::Schema::Field.accepts_definition(:authorize) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 69a60a65e77..2e4aa9c1053 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -22,7 +22,7 @@ Sidekiq.configure_server do |config| config.server_middleware do |chain| chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs - chain.add Gitlab::SidekiqMiddleware::Shutdown + chain.add Gitlab::SidekiqMiddleware::MemoryKiller if ENV['SIDEKIQ_MEMORY_KILLER_MAX_RSS'] chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0' chain.add Gitlab::SidekiqMiddleware::BatchLoader chain.add Gitlab::SidekiqMiddleware::CorrelationLogger @@ -77,6 +77,9 @@ Sidekiq.configure_server do |config| # Avoid autoload issue such as 'Mail::Parsers::AddressStruct' # https://github.com/mikel/mail/issues/912#issuecomment-214850355 Mail.eager_autoload! + + # Ensure the whole process group is terminated if possible + Gitlab::SidekiqSignals.install!(Sidekiq::CLI::SIGNAL_HANDLERS) end Sidekiq.configure_client do |config| |