diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-05 19:20:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-05 19:20:45 +0300 |
commit | d298fad0c0564454271cba11e6f20c19681534ac (patch) | |
tree | 0a19d07d8b3bdd2574617305c300e404f2ace581 /config/initializers | |
parent | c9f9eec79cab801a50db698f682aacffbedf07f7 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc41
Diffstat (limited to 'config/initializers')
85 files changed, 250 insertions, 66 deletions
diff --git a/config/initializers/01_secret_token.rb b/config/initializers/01_secret_token.rb index d7e725477eb..c4520b4b313 100644 --- a/config/initializers/01_secret_token.rb +++ b/config/initializers/01_secret_token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # WARNING: Before you make a change to secrets.yml, read the development guide for GitLab secrets # doc/development/application_secrets.md. # diff --git a/config/initializers/0_acts_as_taggable.rb b/config/initializers/0_acts_as_taggable.rb index 50dc47673ab..9a92b8f2d18 100644 --- a/config/initializers/0_acts_as_taggable.rb +++ b/config/initializers/0_acts_as_taggable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ActsAsTaggableOn.strict_case_match = true # tags_counter enables caching count of tags which results in an update whenever a tag is added or removed diff --git a/config/initializers/0_inject_enterprise_edition_module.rb b/config/initializers/0_inject_enterprise_edition_module.rb index b3ebb44ef25..7478727f869 100644 --- a/config/initializers/0_inject_enterprise_edition_module.rb +++ b/config/initializers/0_inject_enterprise_edition_module.rb @@ -6,12 +6,7 @@ module InjectEnterpriseEditionModule def prepend_if_ee(constant, with_descendants: false) return unless Gitlab.ee? - ee_module = constant.constantize - prepend(ee_module) - - if with_descendants - descendants.each { |descendant| descendant.prepend(ee_module) } - end + prepend_module(constant.constantize, with_descendants) end def extend_if_ee(constant) @@ -21,6 +16,34 @@ module InjectEnterpriseEditionModule def include_if_ee(constant) include(constant.constantize) if Gitlab.ee? end + + def prepend_ee_mod(with_descendants: false) + return unless Gitlab.ee? + + prepend_module(ee_module, with_descendants) + end + + def extend_ee_mod + extend(ee_module) if Gitlab.ee? + end + + def include_ee_mod + include(ee_module) if Gitlab.ee? + end + + private + + def prepend_module(mod, with_descendants) + prepend(mod) + + if with_descendants + descendants.each { |descendant| descendant.prepend(mod) } + end + end + + def ee_module + ::EE.const_get(name, false) + end end Module.prepend(InjectEnterpriseEditionModule) diff --git a/config/initializers/0_inject_feature_flags.rb b/config/initializers/0_inject_feature_flags.rb index 5b33b3bb4ea..daf208bd960 100644 --- a/config/initializers/0_inject_feature_flags.rb +++ b/config/initializers/0_inject_feature_flags.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This needs to be loaded after # config/initializers/0_inject_enterprise_edition_module.rb diff --git a/config/initializers/0_post_deployment_migrations.rb b/config/initializers/0_post_deployment_migrations.rb index 2d647f72840..dabb82c8525 100644 --- a/config/initializers/0_post_deployment_migrations.rb +++ b/config/initializers/0_post_deployment_migrations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Post deployment migrations are included by default. This file must be loaded # before other initializers as Rails may otherwise memoize a list of migrations # excluding the post deployment migrations. diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index bbed08f5044..2d8bab50635 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../settings' require_relative '../object_store_settings' require_relative '../smime_signature_settings' @@ -416,7 +418,7 @@ Settings.cron_jobs['stuck_ci_jobs_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['stuck_ci_jobs_worker']['cron'] ||= '0 * * * *' Settings.cron_jobs['stuck_ci_jobs_worker']['job_class'] = 'StuckCiJobsWorker' Settings.cron_jobs['pipeline_schedule_worker'] ||= Settingslogic.new({}) -Settings.cron_jobs['pipeline_schedule_worker']['cron'] ||= '19 * * * *' +Settings.cron_jobs['pipeline_schedule_worker']['cron'] ||= '3-59/10 * * * *' Settings.cron_jobs['pipeline_schedule_worker']['job_class'] = 'PipelineScheduleWorker' Settings.cron_jobs['expire_build_artifacts_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['expire_build_artifacts_worker']['cron'] ||= '*/7 * * * *' @@ -545,6 +547,12 @@ Settings.cron_jobs['manage_evidence_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['manage_evidence_worker']['cron'] ||= '0 * * * *' Settings.cron_jobs['manage_evidence_worker']['job_class'] = 'Releases::ManageEvidenceWorker' +Gitlab.com do + Settings.cron_jobs['namespaces_in_product_marketing_emails_worker'] ||= Settingslogic.new({}) + Settings.cron_jobs['namespaces_in_product_marketing_emails_worker']['cron'] ||= '0 9 * * *' + Settings.cron_jobs['namespaces_in_product_marketing_emails_worker']['job_class'] = 'Namespaces::InProductMarketingEmailsWorker' +end + Gitlab.ee do Settings.cron_jobs['analytics_devops_adoption_create_all_snapshots_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['analytics_devops_adoption_create_all_snapshots_worker']['cron'] ||= '0 4 * * *' @@ -597,6 +605,9 @@ Gitlab.ee do Settings.cron_jobs['incident_sla_exceeded_check_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['incident_sla_exceeded_check_worker']['cron'] ||= '*/2 * * * *' Settings.cron_jobs['incident_sla_exceeded_check_worker']['job_class'] = 'IncidentManagement::IncidentSlaExceededCheckWorker' + Settings.cron_jobs['incident_management_persist_oncall_rotation_worker'] ||= Settingslogic.new({}) + Settings.cron_jobs['incident_management_persist_oncall_rotation_worker']['cron'] ||= '*/5 * * * *' + Settings.cron_jobs['incident_management_persist_oncall_rotation_worker']['job_class'] = 'IncidentManagement::OncallRotations::PersistAllRotationsShiftsJob' Settings.cron_jobs['import_software_licenses_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['import_software_licenses_worker']['cron'] ||= '0 3 * * 0' Settings.cron_jobs['import_software_licenses_worker']['job_class'] = 'ImportSoftwareLicensesWorker' diff --git a/config/initializers/2_gitlab.rb b/config/initializers/2_gitlab.rb index 8b7f245b7b0..5b78a471f8a 100644 --- a/config/initializers/2_gitlab.rb +++ b/config/initializers/2_gitlab.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require_dependency 'gitlab' diff --git a/config/initializers/5_backend.rb b/config/initializers/5_backend.rb index 46854af9b55..78910bb7675 100644 --- a/config/initializers/5_backend.rb +++ b/config/initializers/5_backend.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + unless Rails.env.test? required_version = Gitlab::VersionInfo.parse(Gitlab::Shell.version_required) current_version = Gitlab::VersionInfo.parse(Gitlab::Shell.version) diff --git a/config/initializers/6_validations.rb b/config/initializers/6_validations.rb index 827b15e5c8d..060b04be824 100644 --- a/config/initializers/6_validations.rb +++ b/config/initializers/6_validations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + def storage_validation_error(message) raise "#{message}. Please fix this in your gitlab.yml before starting GitLab." end diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index 65ff6b656b9..a304f861db8 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'prometheus/client' # Keep separate directories for separate processes @@ -39,6 +41,32 @@ Sidekiq.configure_server do |config| end if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? + # When running Puma in a Single mode, `on_master_start` and `on_worker_start` are the same. + # Thus, we order these events to run `reinitialize_on_pid_change` with `force: true` first. + Gitlab::Cluster::LifecycleEvents.on_master_start do + # Ensure that stale Prometheus metrics don't accumulate over time + Prometheus::CleanupMultiprocDirService.new.execute + + ::Prometheus::Client.reinitialize_on_pid_change(force: true) + + if Gitlab::Runtime.unicorn? + Gitlab::Metrics::Samplers::UnicornSampler.instance(Settings.monitoring.unicorn_sampler_interval).start + elsif Gitlab::Runtime.puma? + Gitlab::Metrics::Samplers::PumaSampler.instance.start + end + + Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION }, 1) + + unless Gitlab::Runtime.sidekiq? + Gitlab::Metrics::RequestsRackMiddleware.initialize_metrics + end + + Gitlab::Ci::Parsers.instrument! + rescue IOError => e + Gitlab::ErrorTracking.track_exception(e) + Gitlab::Metrics.error_detected! + end + Gitlab::Cluster::LifecycleEvents.on_worker_start do defined?(::Prometheus::Client.reinitialize_on_pid_change) && Prometheus::Client.reinitialize_on_pid_change @@ -53,25 +81,8 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? if Gitlab.ee? && Gitlab::Runtime.sidekiq? Gitlab::Metrics::Samplers::GlobalSearchSampler.instance.start end - rescue IOError => e - Gitlab::ErrorTracking.track_exception(e) - Gitlab::Metrics.error_detected! - end - - Gitlab::Cluster::LifecycleEvents.on_master_start do - ::Prometheus::Client.reinitialize_on_pid_change(force: true) - - if Gitlab::Runtime.unicorn? - Gitlab::Metrics::Samplers::UnicornSampler.instance(Settings.monitoring.unicorn_sampler_interval).start - elsif Gitlab::Runtime.puma? - Gitlab::Metrics::Samplers::PumaSampler.instance.start - end - Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION }, 1) - - unless Gitlab::Runtime.sidekiq? - Gitlab::Metrics::RequestsRackMiddleware.initialize_metrics - end + Gitlab::Ci::Parsers.instrument! rescue IOError => e Gitlab::ErrorTracking.track_exception(e) Gitlab::Metrics.error_detected! diff --git a/config/initializers/7_redis.rb b/config/initializers/7_redis.rb index af4967521b8..a6025a6dbf0 100644 --- a/config/initializers/7_redis.rb +++ b/config/initializers/7_redis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Make sure we initialize a Redis connection pool before multi-threaded # execution starts by # 1. Sidekiq diff --git a/config/initializers/8_devise.rb b/config/initializers/8_devise.rb index a4841a11a00..3cac012c2f7 100644 --- a/config/initializers/8_devise.rb +++ b/config/initializers/8_devise.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Use this hook to configure devise mailer, warden hooks and so forth. The first # four configuration values can also be set straight in your models. Devise.setup do |config| diff --git a/config/initializers/8_gitaly.rb b/config/initializers/8_gitaly.rb index f4f116e67f7..d7b5bfbc269 100644 --- a/config/initializers/8_gitaly.rb +++ b/config/initializers/8_gitaly.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'uri' Gitlab.config.repositories.storages.keys.each do |storage| diff --git a/config/initializers/9_fast_gettext.rb b/config/initializers/9_fast_gettext.rb index f836e6e971d..0c28a1b7ce8 100644 --- a/config/initializers/9_fast_gettext.rb +++ b/config/initializers/9_fast_gettext.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + FastGettext.default_available_locales = Gitlab::I18n.available_locales I18n.available_locales = Gitlab::I18n.available_locales diff --git a/config/initializers/action_dispatch_http_mime_negotiation.rb b/config/initializers/action_dispatch_http_mime_negotiation.rb index 6c31de2de55..2d6afb97a60 100644 --- a/config/initializers/action_dispatch_http_mime_negotiation.rb +++ b/config/initializers/action_dispatch_http_mime_negotiation.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Starting with Rails 5, Rails tries to determine the request format based on # the extension of the full URL path if no explicit `format` param or `Accept` # header is provided, like when simply browsing to a page in your browser. diff --git a/config/initializers/action_mailer_hooks.rb b/config/initializers/action_mailer_hooks.rb index 41e34b6eb20..46d5e387d9d 100644 --- a/config/initializers/action_mailer_hooks.rb +++ b/config/initializers/action_mailer_hooks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + unless Gitlab.config.gitlab.email_enabled ActionMailer::Base.register_interceptor(::Gitlab::Email::Hook::DisableEmailInterceptor) ActionMailer::Base.logger = nil diff --git a/config/initializers/active_record_data_types.rb b/config/initializers/active_record_data_types.rb index 3fa999e9908..f8f0a69622f 100644 --- a/config/initializers/active_record_data_types.rb +++ b/config/initializers/active_record_data_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # ActiveRecord custom data type for storing datetimes with timezone information. # See https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/11229 diff --git a/config/initializers/active_record_ping.rb b/config/initializers/active_record_ping.rb index 349a7e4a496..196f587f565 100644 --- a/config/initializers/active_record_ping.rb +++ b/config/initializers/active_record_ping.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # frozen_string_literal: true if Gitlab::Utils.to_boolean(ENV['ENABLE_ACTIVERECORD_EMPTY_PING'], default: false) diff --git a/config/initializers/active_record_preloader.rb b/config/initializers/active_record_preloader.rb index d585ecda307..349ca6c4831 100644 --- a/config/initializers/active_record_preloader.rb +++ b/config/initializers/active_record_preloader.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ActiveRecord module Associations class Preloader diff --git a/config/initializers/active_record_schema_ignore_tables.rb b/config/initializers/active_record_schema_ignore_tables.rb index 0a840bbf1d8..55c44e00c40 100644 --- a/config/initializers/active_record_schema_ignore_tables.rb +++ b/config/initializers/active_record_schema_ignore_tables.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + # Ignore dynamically managed partitions in static application schema ActiveRecord::SchemaDumper.ignore_tables += ["#{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.*"] diff --git a/config/initializers/active_record_table_definition.rb b/config/initializers/active_record_table_definition.rb index 9220620da41..3c6311f034f 100644 --- a/config/initializers/active_record_table_definition.rb +++ b/config/initializers/active_record_table_definition.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # ActiveRecord custom method definitions with timezone information. # See https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/11229 diff --git a/config/initializers/ar_speed_up_migration_checking.rb b/config/initializers/ar_speed_up_migration_checking.rb index c4ffcc54cb2..778b2ee0cb1 100644 --- a/config/initializers/ar_speed_up_migration_checking.rb +++ b/config/initializers/ar_speed_up_migration_checking.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if Rails.env.test? require 'active_record/migration' diff --git a/config/initializers/asset_proxy_settings.rb b/config/initializers/asset_proxy_settings.rb index 92247aba1b8..48eedcee681 100644 --- a/config/initializers/asset_proxy_settings.rb +++ b/config/initializers/asset_proxy_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Asset proxy settings # diff --git a/config/initializers/attr_encrypted_no_db_connection.rb b/config/initializers/attr_encrypted_no_db_connection.rb index 7ad458929db..f8d0effbbad 100644 --- a/config/initializers/attr_encrypted_no_db_connection.rb +++ b/config/initializers/attr_encrypted_no_db_connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AttrEncrypted module Adapters module ActiveRecord diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 2f892f78112..f3e01d23448 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.backtrace_cleaner.remove_silencers! # This allows us to see the proper caller of SQL calls in {development,test}.log diff --git a/config/initializers/batch_loader.rb b/config/initializers/batch_loader.rb index 2e2256b0eb9..d88b43fbcea 100644 --- a/config/initializers/batch_loader.rb +++ b/config/initializers/batch_loader.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Rails.application.config.middleware.use(BatchLoader::Middleware) diff --git a/config/initializers/bootstrap_form.rb b/config/initializers/bootstrap_form.rb index bbc1d83a63f..8121bc8bf1d 100644 --- a/config/initializers/bootstrap_form.rb +++ b/config/initializers/bootstrap_form.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module BootstrapFormBuilderCustomization def label_class "label-bold" diff --git a/config/initializers/bullet.rb b/config/initializers/bullet.rb index d1f72ca3ce7..2d21514b121 100644 --- a/config/initializers/bullet.rb +++ b/config/initializers/bullet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + def bullet_enabled? Gitlab::Utils.to_boolean(ENV['ENABLE_BULLET'].to_s) end diff --git a/config/initializers/cluster_events_before_phased_restart.rb b/config/initializers/cluster_events_before_phased_restart.rb index aae5470d6ae..d029adbe363 100644 --- a/config/initializers/cluster_events_before_phased_restart.rb +++ b/config/initializers/cluster_events_before_phased_restart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Technical debt, this should be ideally upstreamed. # # However, there's currently no way to hook before doing diff --git a/config/initializers/console_message.rb b/config/initializers/console_message.rb index fe47195062b..2c05c2c9a24 100644 --- a/config/initializers/console_message.rb +++ b/config/initializers/console_message.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # rubocop:disable Rails/Output if Gitlab::Runtime.console? # note that this will not print out when using `spring` diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index e9a71f32581..375a23fdfd6 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.use_cookies_with_metadata = true diff --git a/config/initializers/date_time_formats.rb b/config/initializers/date_time_formats.rb index 1939ced512d..44d07869033 100644 --- a/config/initializers/date_time_formats.rb +++ b/config/initializers/date_time_formats.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # :short - 10 Nov # :medium - Nov 10, 2007 # :long - November 10, 2007 diff --git a/config/initializers/default_url_options.rb b/config/initializers/default_url_options.rb index de2cdc6ecae..138a8e467c7 100644 --- a/config/initializers/default_url_options.rb +++ b/config/initializers/default_url_options.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + default_url_options = { host: Gitlab.config.gitlab.host, protocol: Gitlab.config.gitlab.protocol, diff --git a/config/initializers/deprecations.rb b/config/initializers/deprecations.rb index 2b07ca665e2..3d03efe67e0 100644 --- a/config/initializers/deprecations.rb +++ b/config/initializers/deprecations.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if Rails.env.development? || ENV['GITLAB_LEGACY_PATH_LOG_MESSAGE'] deprecator = ActiveSupport::Deprecation.new('11.0', 'GitLab') diff --git a/config/initializers/direct_upload_support.rb b/config/initializers/direct_upload_support.rb index 919b80b79c0..880aea7d114 100644 --- a/config/initializers/direct_upload_support.rb +++ b/config/initializers/direct_upload_support.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DirectUploadsValidator SUPPORTED_DIRECT_UPLOAD_PROVIDERS = [ObjectStorage::Config::GOOGLE_PROVIDER, ObjectStorage::Config::AWS_PROVIDER, diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 6b54b5074d5..1cf70909997 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Doorkeeper.configure do # Change the ORM that doorkeeper will use. # Currently supported options are :active_record, :mongoid2, :mongoid3, :mongo_mapper diff --git a/config/initializers/doorkeeper_openid_connect.rb b/config/initializers/doorkeeper_openid_connect.rb index 3523776c4f7..12a963ce45d 100644 --- a/config/initializers/doorkeeper_openid_connect.rb +++ b/config/initializers/doorkeeper_openid_connect.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Doorkeeper::OpenidConnect.configure do issuer Gitlab.config.gitlab.url diff --git a/config/initializers/etag_caching.rb b/config/initializers/etag_caching.rb index eba88801141..2e5574d2602 100644 --- a/config/initializers/etag_caching.rb +++ b/config/initializers/etag_caching.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This middleware has to come after Gitlab::Metrics::RackMiddleware # in the middleware stack, because it tracks events with # GitLab Performance Monitoring diff --git a/config/initializers/faraday.rb b/config/initializers/faraday.rb new file mode 100644 index 00000000000..2700751e79f --- /dev/null +++ b/config/initializers/faraday.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +::Faraday::Request.register_middleware(gitlab_error_callback: -> { ::Gitlab::Faraday::ErrorCallback }) diff --git a/config/initializers/fill_shards.rb b/config/initializers/fill_shards.rb index 90c0d63e4fe..e2889f59574 100644 --- a/config/initializers/fill_shards.rb +++ b/config/initializers/fill_shards.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # The explicit schema version check is needed because during our migration rollback testing, # `Shard.connected?` could be cached and return true even though the table doesn't exist return unless Shard.connected? diff --git a/config/initializers/fix_local_cache_middleware.rb b/config/initializers/fix_local_cache_middleware.rb index 2644ee6a7d3..94da6d9c0e0 100644 --- a/config/initializers/fix_local_cache_middleware.rb +++ b/config/initializers/fix_local_cache_middleware.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module LocalCacheRegistryCleanupWithEnsure LocalCacheRegistry = ActiveSupport::Cache::Strategy::LocalCache::LocalCacheRegistry diff --git a/config/initializers/fog_google_https_private_urls.rb b/config/initializers/fog_google_https_private_urls.rb index ef6afb2b686..78cbd41a609 100644 --- a/config/initializers/fog_google_https_private_urls.rb +++ b/config/initializers/fog_google_https_private_urls.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # # Monkey patching the https support for private urls # See https://gitlab.com/gitlab-org/gitlab/issues/4879 diff --git a/config/initializers/forbid_sidekiq_in_transactions.rb b/config/initializers/forbid_sidekiq_in_transactions.rb index f505fb5843a..85ec8cad0a3 100644 --- a/config/initializers/forbid_sidekiq_in_transactions.rb +++ b/config/initializers/forbid_sidekiq_in_transactions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Sidekiq module Worker EnqueueFromTransactionError = Class.new(StandardError) diff --git a/config/initializers/gettext_rails_i18n_patch.rb b/config/initializers/gettext_rails_i18n_patch.rb index 09c9b325a04..c23049e93c9 100644 --- a/config/initializers/gettext_rails_i18n_patch.rb +++ b/config/initializers/gettext_rails_i18n_patch.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'gettext_i18n_rails/haml_parser' require 'gettext_i18n_rails_js/parser/javascript' require 'json' diff --git a/config/initializers/gitlab_kas_secret.rb b/config/initializers/gitlab_kas_secret.rb index 5e86e954684..8955f71a597 100644 --- a/config/initializers/gitlab_kas_secret.rb +++ b/config/initializers/gitlab_kas_secret.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Gitlab::Kas.ensure_secret! diff --git a/config/initializers/gitlab_shell_secret_token.rb b/config/initializers/gitlab_shell_secret_token.rb index 529dcdd4644..e11f65bb8ca 100644 --- a/config/initializers/gitlab_shell_secret_token.rb +++ b/config/initializers/gitlab_shell_secret_token.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Gitlab::Shell.ensure_secret_token! diff --git a/config/initializers/gitlab_workhorse_secret.rb b/config/initializers/gitlab_workhorse_secret.rb index ed54dc11098..5c959a72bd1 100644 --- a/config/initializers/gitlab_workhorse_secret.rb +++ b/config/initializers/gitlab_workhorse_secret.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin Gitlab::Workhorse.secret rescue diff --git a/config/initializers/go_get.rb b/config/initializers/go_get.rb index 7e7896b4900..830579f4a8a 100644 --- a/config/initializers/go_get.rb +++ b/config/initializers/go_get.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Rails.application.config.middleware.use(Gitlab::Middleware::Go) diff --git a/config/initializers/grpc.rb b/config/initializers/grpc.rb index b96962fe7db..66b212ef131 100644 --- a/config/initializers/grpc.rb +++ b/config/initializers/grpc.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' GRPC_LOGGER = Logger.new(Rails.root.join('log/grpc.log')) diff --git a/config/initializers/hamlit.rb b/config/initializers/hamlit.rb index b5bcae4bbfc..dda38d2a61f 100644 --- a/config/initializers/hamlit.rb +++ b/config/initializers/hamlit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Hamlit::RailsTemplate.set_options(attr_quote: '"') Hamlit::Filters.remove_filter('coffee') diff --git a/config/initializers/health_check.rb b/config/initializers/health_check.rb index 1496f20afc1..0b35aaf115b 100644 --- a/config/initializers/health_check.rb +++ b/config/initializers/health_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + HealthCheck.setup do |config| config.standard_checks = %w(database migrations cache) config.full_checks = %w(database migrations cache) diff --git a/config/initializers/http_hostname_override.rb b/config/initializers/http_hostname_override.rb index 58dd380326f..5d2739c1f58 100644 --- a/config/initializers/http_hostname_override.rb +++ b/config/initializers/http_hostname_override.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This override allows passing `@hostname_override` to the SNI protocol, # which is used to lookup the correct SSL certificate in the # request handshake process. diff --git a/config/initializers/kaminari_active_record_relation_methods_with_limit.rb b/config/initializers/kaminari_active_record_relation_methods_with_limit.rb index 55b98cda520..982cb69e532 100644 --- a/config/initializers/kaminari_active_record_relation_methods_with_limit.rb +++ b/config/initializers/kaminari_active_record_relation_methods_with_limit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kaminari # Active Record specific page scope methods implementations module ActiveRecordRelationMethodsWithLimit diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index 3cbe9a058d7..8e10079ce36 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Kaminari.configure do |config| config.default_per_page = 20 config.max_per_page = 100 diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index 5b068c15aad..e8479bc6aa4 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Only use Lograge for Rails unless Gitlab::Runtime.sidekiq? Rails.application.reloader.to_prepare do diff --git a/config/initializers/mail_encoding_patch.rb b/config/initializers/mail_encoding_patch.rb index d53b058ba75..11a96625e08 100644 --- a/config/initializers/mail_encoding_patch.rb +++ b/config/initializers/mail_encoding_patch.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Monkey patch mail 2.7.1 to fix quoted-printable issues with newlines # The issues upstream invalidate SMIME signatures under some conditions # This was working properly in 2.6.6 diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index acbdf8de5a6..5329232cc92 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/mini_magick.rb b/config/initializers/mini_magick.rb index db0e7bbaaa3..8e3e55279f7 100644 --- a/config/initializers/mini_magick.rb +++ b/config/initializers/mini_magick.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + MiniMagick.configure do |config| config.cli = :graphicsmagick end diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 115ee08dbb6..3d3ee5299e2 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Remove this `if` condition when upgraded to rails 5.0. # The body must be kept. # Be sure to restart your server when you modify this file. diff --git a/config/initializers/octokit.rb b/config/initializers/octokit.rb index b3749258ec5..cd8c8ec24ee 100644 --- a/config/initializers/octokit.rb +++ b/config/initializers/octokit.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Octokit.middleware.insert_after Octokit::Middleware::FollowRedirects, Gitlab::Octokit::Middleware diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index a2720ab9986..85984772d05 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if Gitlab::Auth::Ldap::Config.enabled? module OmniAuth::Strategies Gitlab::Auth::Ldap::Config.available_servers.each do |server| diff --git a/config/initializers/peek.rb b/config/initializers/peek.rb index fa74d8620f4..85bfc4f0214 100644 --- a/config/initializers/peek.rb +++ b/config/initializers/peek.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'peek/adapters/redis' Peek::Adapters::Redis.prepend ::Gitlab::PerformanceBar::RedisAdapterWhenPeekEnabled @@ -11,6 +13,7 @@ Peek.into Peek::Views::Gitaly Peek.into Peek::Views::RedisDetailed Peek.into Peek::Views::Elasticsearch Peek.into Peek::Views::Rugged +Peek.into Peek::Views::ExternalHttp Peek.into Peek::Views::BulletDetailed if defined?(Bullet) Peek.into Peek::Views::Tracing if Labkit::Tracing.tracing_url_enabled? diff --git a/config/initializers/postgresql_cte.rb b/config/initializers/postgresql_cte.rb index 68d53c4edbf..1ea0b4cfb58 100644 --- a/config/initializers/postgresql_cte.rb +++ b/config/initializers/postgresql_cte.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Adds support for WITH statements when using PostgreSQL. The code here is taken # from https://github.com/shmay/ctes_in_my_pg which at the time of writing has # not been pushed to RubyGems. The license of this repository is as follows: diff --git a/config/initializers/premailer.rb b/config/initializers/premailer.rb index 87f8e67ef1c..77077888af3 100644 --- a/config/initializers/premailer.rb +++ b/config/initializers/premailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # See https://github.com/fphilipe/premailer-rails#configuration Premailer::Rails.config.merge!( generate_text_part: false, diff --git a/config/initializers/query_limiting.rb b/config/initializers/query_limiting.rb index 66864d1898e..66aefc97c6a 100644 --- a/config/initializers/query_limiting.rb +++ b/config/initializers/query_limiting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if Gitlab::QueryLimiting.enable? require_dependency 'gitlab/query_limiting/active_support_subscriber' require_dependency 'gitlab/query_limiting/transaction' diff --git a/config/initializers/rack_attack_logging.rb b/config/initializers/rack_attack_logging.rb deleted file mode 100644 index 7b0a8f0d7dd..00000000000 --- a/config/initializers/rack_attack_logging.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true -# -# Adds logging for all Rack Attack blocks and throttling events. - -ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, request_id, payload| - req = payload[:request] - - case req.env['rack.attack.match_type'] - when :throttle, :blocklist, :track - rack_attack_info = { - message: 'Rack_Attack', - env: req.env['rack.attack.match_type'], - remote_ip: req.ip, - request_method: req.request_method, - path: req.fullpath, - matched: req.env['rack.attack.matched'] - } - - throttles_with_user_information = [ - :throttle_authenticated_api, - :throttle_authenticated_web, - :throttle_authenticated_protected_paths_api, - :throttle_authenticated_protected_paths_web - ] - - if throttles_with_user_information.include? req.env['rack.attack.matched'].to_sym - user_id = req.env['rack.attack.match_discriminator'] - user = User.find_by(id: user_id) - - rack_attack_info[:user_id] = user_id - rack_attack_info['meta.user'] = user.username unless user.nil? - end - - Gitlab::AuthLogger.error(rack_attack_info) - when :safelist - Gitlab::Instrumentation::Throttle.safelist = req.env['rack.attack.matched'] - end -end diff --git a/config/initializers/rack_lineprof.rb b/config/initializers/rack_lineprof.rb index f7172fce9bc..e66bfd88907 100644 --- a/config/initializers/rack_lineprof.rb +++ b/config/initializers/rack_lineprof.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # The default colors of rack-lineprof can be very hard to look at in terminals # with darker backgrounds. This patch tweaks the colors a bit so the output is # actually readable. diff --git a/config/initializers/relative_naming_ci_namespace.rb b/config/initializers/relative_naming_ci_namespace.rb index d9d3034150f..7380597722a 100644 --- a/config/initializers/relative_naming_ci_namespace.rb +++ b/config/initializers/relative_naming_ci_namespace.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Description: https://coderwall.com/p/heed_q/rails-routing-and-namespaced-models # # This allows us to use CI ActiveRecord objects in all routes and use it: diff --git a/config/initializers/request_context.rb b/config/initializers/request_context.rb index f79f1f32d70..99e51ce498a 100644 --- a/config/initializers/request_context.rb +++ b/config/initializers/request_context.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do |config| config.middleware.insert_after RequestStore::Middleware, Gitlab::Middleware::RequestContext end diff --git a/config/initializers/request_profiler.rb b/config/initializers/request_profiler.rb index fb5a7b8372e..8e426772b9a 100644 --- a/config/initializers/request_profiler.rb +++ b/config/initializers/request_profiler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do |config| config.middleware.use(Gitlab::RequestProfiler::Middleware) end diff --git a/config/initializers/routing_draw.rb b/config/initializers/routing_draw.rb index f0f74954eef..4978073633c 100644 --- a/config/initializers/routing_draw.rb +++ b/config/initializers/routing_draw.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Adds draw method into Rails routing # It allows us to keep routing split into files ActionDispatch::Routing::Mapper.prepend Gitlab::Patch::DrawRoute diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index a1eddd6a2c2..df80d4f7f73 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. require 'gitlab/current_settings' diff --git a/config/initializers/server_uptime.rb b/config/initializers/server_uptime.rb index 46bf242e143..9e58a848007 100644 --- a/config/initializers/server_uptime.rb +++ b/config/initializers/server_uptime.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Rails.application.config.booted_at = Time.now diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index da24881885e..6e0cd33aa96 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. require 'gitlab/current_settings' diff --git a/config/initializers/sherlock.rb b/config/initializers/sherlock.rb index 8f2ababb712..ba33ffa13c5 100644 --- a/config/initializers/sherlock.rb +++ b/config/initializers/sherlock.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + if Gitlab::Sherlock.enabled? Rails.application.configure do |config| config.middleware.use(Gitlab::Sherlock::Middleware) diff --git a/config/initializers/sprockets.rb b/config/initializers/sprockets.rb index a20b7dc75e9..d0660574eb6 100644 --- a/config/initializers/sprockets.rb +++ b/config/initializers/sprockets.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + Sprockets.register_compressor 'application/javascript', :terser, Terser::Compressor diff --git a/config/initializers/static_files.rb b/config/initializers/static_files.rb index 4e19fec084a..3cdb5a5abcf 100644 --- a/config/initializers/static_files.rb +++ b/config/initializers/static_files.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + app = Rails.application if app.config.public_file_server.enabled diff --git a/config/initializers/time_zone.rb b/config/initializers/time_zone.rb index bca7411ad63..8ad6b2d3447 100644 --- a/config/initializers/time_zone.rb +++ b/config/initializers/time_zone.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Time.zone = Gitlab.config.gitlab.time_zone || Time.zone # The default is normally set by Rails in the # active_support.initialize_time_zone Railtie, but we need to set it diff --git a/config/initializers/tracing.rb b/config/initializers/tracing.rb index 3058bdeb84e..3f066953c23 100644 --- a/config/initializers/tracing.rb +++ b/config/initializers/tracing.rb @@ -8,6 +8,7 @@ if Labkit::Tracing.enabled? # Instrument Redis Labkit::Tracing::Redis.instrument + Labkit::Tracing::ExternalHttp.instrument # Instrument Rails Labkit::Tracing::Rails::ActiveRecordSubscriber.instrument diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb index a4528020c06..79e4b831c5e 100644 --- a/config/initializers/trusted_proxies.rb +++ b/config/initializers/trusted_proxies.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Override Rack::Request to make use of the same list of trusted_proxies # as the ActionDispatch::Request object. This is necessary for libraries # like rack_attack where they don't use ActionDispatch, and we want them diff --git a/config/initializers/validate_puma.rb b/config/initializers/validate_puma.rb index ac5678c4b5a..bce9ddb9a66 100644 --- a/config/initializers/validate_puma.rb +++ b/config/initializers/validate_puma.rb @@ -1,5 +1,13 @@ # frozen_string_literal: true +def allow_single_mode? + return false if Gitlab.com? + + Gitlab::Utils.to_boolean(ENV['PUMA_SKIP_CLUSTER_VALIDATION']) +end + if Gitlab::Runtime.puma? && ::Puma.cli_config.options[:workers].to_i == 0 + return if allow_single_mode? + raise 'Puma is only supported in Cluster-mode: workers > 0' end diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index 3cfab52efd1..2517c0cf5c2 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do |config| Warden::Manager.after_set_user(scope: :user) do |user, auth, opts| Gitlab::Auth::UniqueIpsLimiter.limit_user!(user) diff --git a/config/initializers/workhorse_multipart.rb b/config/initializers/workhorse_multipart.rb index 9c170d1adfa..b68a6fc6ee5 100644 --- a/config/initializers/workhorse_multipart.rb +++ b/config/initializers/workhorse_multipart.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Rails.application.configure do |config| # ApolloUploadServer::Middleware expects to find uploaded files ready to use config.middleware.insert_before(ApolloUploadServer::Middleware, Gitlab::Middleware::Multipart) diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df20181e..85b2d840618 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which diff --git a/config/initializers/zz_metrics.rb b/config/initializers/zz_metrics.rb index 430e4d60d61..d0e22187454 100644 --- a/config/initializers/zz_metrics.rb +++ b/config/initializers/zz_metrics.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was prefixed with zz_ because we want to load it the last! # See: https://gitlab.com/gitlab-org/gitlab-foss/issues/55611 @@ -154,9 +156,13 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d # of the ActiveRecord methods. This has to take place _after_ initializing as # for some unknown reason calling eager_load! earlier breaks Devise. Gitlab::Application.config.after_initialize do - Rails.application.eager_load! + # We should move all the logic of this file to somewhere else + # and require it after `Rails.application.initialize!` in `environment.rb` file. + models_path = Rails.root.join('app', 'models').to_s - models = Rails.root.join('app', 'models').to_s + Dir.glob("**/*.rb", base: models_path).sort.each do |file| + require_dependency file + end regex = Regexp.union( ActiveRecord::Querying.public_instance_methods(false).map(&:to_s) @@ -172,7 +178,7 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d else loc = method.source_location - loc && loc[0].start_with?(models) && method.source =~ regex + loc && loc[0].start_with?(models_path) && method.source =~ regex end end @@ -202,4 +208,8 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d class ::Redis::Client prepend TrackNewRedisConnections end + + Labkit::NetHttpPublisher.labkit_prepend! + Labkit::ExconPublisher.labkit_prepend! + Labkit::HTTPClientPublisher.labkit_prepend! end |