diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-21 17:21:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-21 17:21:10 +0300 |
commit | cb0d23c455b73486fd1015f8ca9479b5b7e3585d (patch) | |
tree | d7dc129a407fd74266d2dc561bebf24665197c2f /config | |
parent | c3e911be175c0aabfea1eb030f9e0ef23f5f3887 (diff) |
Add latest changes from gitlab-org/gitlab@12-7-stable-ee
Diffstat (limited to 'config')
35 files changed, 346 insertions, 225 deletions
diff --git a/config/application.rb b/config/application.rb index 33c1c1b90d2..304cd72e806 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,10 +18,10 @@ module Gitlab require_dependency Rails.root.join('lib/gitlab/redis/cache') require_dependency Rails.root.join('lib/gitlab/redis/queues') require_dependency Rails.root.join('lib/gitlab/redis/shared_state') - require_dependency Rails.root.join('lib/gitlab/request_context') require_dependency Rails.root.join('lib/gitlab/current_settings') require_dependency Rails.root.join('lib/gitlab/middleware/read_only') require_dependency Rails.root.join('lib/gitlab/middleware/basic_health_check') + require_dependency Rails.root.join('lib/gitlab/runtime') # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -165,7 +165,7 @@ module Gitlab config.assets.precompile << "page_bundles/xterm.css" config.assets.precompile << "performance_bar.css" config.assets.precompile << "lib/ace.js" - config.assets.precompile << "test.css" + config.assets.precompile << "disable_animations.css" config.assets.precompile << "snippets.css" config.assets.precompile << "locale/**/app.js" config.assets.precompile << "emoji_sprites.css" @@ -228,13 +228,15 @@ module Gitlab # Allow access to GitLab API from other domains config.middleware.insert_before Warden::Manager, Rack::Cors do + headers_to_expose = %w[Link X-Total X-Total-Pages X-Per-Page X-Page X-Next-Page X-Prev-Page X-Gitlab-Blob-Id X-Gitlab-Commit-Id X-Gitlab-Content-Sha256 X-Gitlab-Encoding X-Gitlab-File-Name X-Gitlab-File-Path X-Gitlab-Last-Commit-Id X-Gitlab-Ref X-Gitlab-Size] + allow do origins Gitlab.config.gitlab.url resource '/api/*', credentials: true, headers: :any, methods: :any, - expose: ['Link', 'X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page'] + expose: headers_to_expose end # Cross-origin requests must not have the session cookie available @@ -244,7 +246,7 @@ module Gitlab credentials: false, headers: :any, methods: :any, - expose: ['Link', 'X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page'] + expose: headers_to_expose end end @@ -255,7 +257,7 @@ module Gitlab caching_config_hash[:compress] = false caching_config_hash[:namespace] = Gitlab::Redis::Cache::CACHE_NAMESPACE caching_config_hash[:expires_in] = 2.weeks # Cache should not grow forever - if Sidekiq.server? || defined?(::Puma) # threaded context + if Gitlab::Runtime.multi_threaded? caching_config_hash[:pool_size] = Gitlab::Redis::Cache.pool_size caching_config_hash[:pool_timeout] = 1 end diff --git a/config/environments/development.rb b/config/environments/development.rb index 2939e13ef94..dc804197fef 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -46,7 +46,7 @@ Rails.application.configure do # Do not log asset requests config.assets.quiet = true - config.allow_concurrency = defined?(::Puma) + config.allow_concurrency = Gitlab::Runtime.multi_threaded? # BetterErrors live shell (REPL) on every stack frame BetterErrors::Middleware.allow_ip!("127.0.0.1/0") diff --git a/config/environments/production.rb b/config/environments/production.rb index 09bcf49a9a5..7ec18547b2f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -75,5 +75,5 @@ Rails.application.configure do config.eager_load = true - config.allow_concurrency = defined?(::Puma) + config.allow_concurrency = Gitlab::Runtime.multi_threaded? end diff --git a/config/feature_categories.yml b/config/feature_categories.yml index 59752a81f60..1cae9875eac 100644 --- a/config/feature_categories.yml +++ b/config/feature_categories.yml @@ -8,10 +8,10 @@ # --- - accessibility_testing -- account-management -- agile_portfolio_management - analysis -- audit_management +- attack_emulation +- audit_events +- audit_reports - authentication_and_authorization - auto_devops - backup_restore @@ -21,29 +21,32 @@ - cloud_native_installation - cluster_cost_optimization - cluster_monitoring -- code_analytics - code_quality - code_review - collection +- compliance_controls +- compliance_frameworks - container_network_security - container_registry - container_scanning - continuous_delivery - continuous_integration - data_loss_prevention +- ddos_protection - dependency_proxy - dependency_scanning - design_management - devops_score - disaster_recovery - dynamic_application_security_testing +- epics - error_tracking - feature_flags - fuzzing - geo_replication - gitaly +- gitlab_handbook - gitter -- groups - helm_chart_registry - importers - incident_management @@ -55,12 +58,13 @@ - internationalization - issue_tracking - kanban_boards -- kubernetes_configuration +- kubernetes_management - language_specific - license_compliance - live_coding - load_testing - logging +- malware_scanning - metrics - omnibus_package - package_registry @@ -69,7 +73,9 @@ - release_governance - release_orchestration - requirements_management +- responsible_disclosure - review_apps +- roadmaps - runbooks - runner - runtime_application_self_protection @@ -82,8 +88,9 @@ - snippets - source_code_management - static_application_security_testing +- static_site_editor - status_page -- storage_security +- subgroups - synthetic_monitoring - system_testing - templates @@ -100,4 +107,3 @@ - web_ide - web_performance - wiki -- workflow_policies diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 5ac9b7ee6e5..5f078459bc2 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -33,6 +33,9 @@ production: &base host: localhost port: 80 # Set to 443 if using HTTPS, see installation.md#using-https for additional HTTPS configuration details https: false # Set to true if using HTTPS, see installation.md#using-https for additional HTTPS configuration details + # The maximum time unicorn/puma can spend on the request. This needs to be smaller than the worker timeout. + # Default is 95% of the worker timeout + max_request_duration_seconds: 57 # Uncomment this line below if your ssh host is different from HTTP/HTTPS one # (you'd obviously need to replace ssh.host_example.com with your own host). @@ -150,6 +153,9 @@ production: &base ## Impersonation settings impersonation_enabled: true + ## Disable jQuery and CSS animations + # disable_animations: true + ## Reply by email # Allow users to comment on issues and merge requests by replying to notification emails. # For documentation on how to set this up, see http://doc.gitlab.com/ce/administration/reply_by_email.html @@ -807,7 +813,7 @@ production: &base # CAUTION! # This allows users to login with the specified providers without two factor. Define the allowed providers # using an array, e.g. ["twitter", 'google_oauth2'], or as true/false to allow all providers or none. - # This option should only be configured for providers which already have two factor. + # This option should only be configured for providers which already have two factor. # This configration dose not apply to SAML. # (default: false) allow_bypass_two_factor: ["twitter", 'google_oauth2'] diff --git a/config/initializers/0_runtime_identify.rb b/config/initializers/0_runtime_identify.rb new file mode 100644 index 00000000000..e6be19ffb79 --- /dev/null +++ b/config/initializers/0_runtime_identify.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +begin + Gitlab::Runtime.identify +rescue Gitlab::Runtime::IdentificationError => e + message = <<-NOTICE + \n!! RUNTIME IDENTIFICATION FAILED: #{e} + Runtime based configuration settings may not work properly. + If you continue to see this error, please file an issue via + https://gitlab.com/gitlab-org/gitlab/issues/new + NOTICE + Gitlab::AppLogger.error(message) + Gitlab::ErrorTracking.track_exception(e) +end diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 691e4339bf0..d7d4bd9d3a1 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -162,8 +162,8 @@ Settings.gitlab['default_projects_limit'] ||= 100000 Settings.gitlab['default_branch_protection'] ||= 2 Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil? Settings.gitlab['default_theme'] = Gitlab::Themes::APPLICATION_DEFAULT if Settings.gitlab['default_theme'].nil? -Settings.gitlab['host'] ||= ENV['GITLAB_HOST'] || 'localhost' -Settings.gitlab['ssh_host'] ||= Settings.gitlab.host +Settings.gitlab['host'] ||= ENV['GITLAB_HOST'] || 'localhost' +Settings.gitlab['ssh_host'] ||= Settings.gitlab.host Settings.gitlab['https'] = false if Settings.gitlab['https'].nil? Settings.gitlab['port'] ||= ENV['GITLAB_PORT'] || (Settings.gitlab.https ? 443 : 80) Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || '' @@ -176,10 +176,10 @@ Settings.gitlab['email_display_name'] ||= ENV['GITLAB_EMAIL_DISPLAY_NAME'] || 'G Settings.gitlab['email_reply_to'] ||= ENV['GITLAB_EMAIL_REPLY_TO'] || "noreply@#{Settings.gitlab.host}" Settings.gitlab['email_subject_suffix'] ||= ENV['GITLAB_EMAIL_SUBJECT_SUFFIX'] || "" Settings.gitlab['email_smime'] = SmimeSignatureSettings.parse(Settings.gitlab['email_smime']) -Settings.gitlab['base_url'] ||= Settings.__send__(:build_base_gitlab_url) -Settings.gitlab['url'] ||= Settings.__send__(:build_gitlab_url) -Settings.gitlab['user'] ||= 'git' -Settings.gitlab['user_home'] ||= begin +Settings.gitlab['base_url'] ||= Settings.__send__(:build_base_gitlab_url) +Settings.gitlab['url'] ||= Settings.__send__(:build_gitlab_url) +Settings.gitlab['user'] ||= 'git' +Settings.gitlab['user_home'] ||= begin Etc.getpwnam(Settings.gitlab['user']).dir rescue ArgumentError # no user configured '/home/' + Settings.gitlab['user'] @@ -209,6 +209,7 @@ Settings.gitlab['content_security_policy'] ||= Gitlab::ContentSecurityPolicy::Co Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml')) Settings.gitlab['impersonation_enabled'] ||= true if Settings.gitlab['impersonation_enabled'].nil? Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil? +Settings.gitlab['max_request_duration_seconds'] ||= 57 Gitlab.ee do Settings.gitlab['mirror_max_delay'] ||= 300 @@ -257,13 +258,13 @@ Settings.artifacts['object_store'] = ObjectStoreSettings.parse(Settings.artifact # Registry # Settings['registry'] ||= Settingslogic.new({}) -Settings.registry['enabled'] ||= false -Settings.registry['host'] ||= "example.com" -Settings.registry['port'] ||= nil -Settings.registry['api_url'] ||= "http://localhost:5000/" -Settings.registry['key'] ||= nil -Settings.registry['issuer'] ||= nil -Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':') +Settings.registry['enabled'] ||= false +Settings.registry['host'] ||= "example.com" +Settings.registry['port'] ||= nil +Settings.registry['api_url'] ||= "http://localhost:5000/" +Settings.registry['key'] ||= nil +Settings.registry['issuer'] ||= nil +Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':') Settings.registry['path'] = Settings.absolute(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry')) Settings.registry['notifications'] ||= [] @@ -284,13 +285,13 @@ Settings.pages['enabled'] = false if Settings.pages['enabled'].nil? Settings.pages['access_control'] = false if Settings.pages['access_control'].nil? Settings.pages['path'] = Settings.absolute(Settings.pages['path'] || File.join(Settings.shared['path'], "pages")) Settings.pages['https'] = false if Settings.pages['https'].nil? -Settings.pages['host'] ||= "example.com" -Settings.pages['port'] ||= Settings.pages.https ? 443 : 80 -Settings.pages['protocol'] ||= Settings.pages.https ? "https" : "http" -Settings.pages['url'] ||= Settings.__send__(:build_pages_url) -Settings.pages['external_http'] ||= false unless Settings.pages['external_http'].present? -Settings.pages['external_https'] ||= false unless Settings.pages['external_https'].present? -Settings.pages['artifacts_server'] ||= Settings.pages['enabled'] if Settings.pages['artifacts_server'].nil? +Settings.pages['host'] ||= "example.com" +Settings.pages['port'] ||= Settings.pages.https ? 443 : 80 +Settings.pages['protocol'] ||= Settings.pages.https ? "https" : "http" +Settings.pages['url'] ||= Settings.__send__(:build_pages_url) +Settings.pages['external_http'] ||= false unless Settings.pages['external_http'].present? +Settings.pages['external_https'] ||= false unless Settings.pages['external_https'].present? +Settings.pages['artifacts_server'] ||= Settings.pages['enabled'] if Settings.pages['artifacts_server'].nil? Settings.pages['secret_file'] ||= Rails.root.join('.gitlab_pages_secret') # @@ -364,7 +365,7 @@ Gitlab.ee do # To ensure acceptable performance we only allow feature to be used with # multithreaded web-server Puma. This will be removed once download logic is moved # to GitLab workhorse - Settings.dependency_proxy['enabled'] = false unless defined?(::Puma) + Settings.dependency_proxy['enabled'] = false unless Gitlab::Runtime.puma? end # @@ -467,6 +468,9 @@ Settings.cron_jobs['schedule_migrate_external_diffs_worker']['job_class'] = 'Sch Settings.cron_jobs['namespaces_prune_aggregation_schedules_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['namespaces_prune_aggregation_schedules_worker']['cron'] ||= '5 1 * * *' Settings.cron_jobs['namespaces_prune_aggregation_schedules_worker']['job_class'] = 'Namespaces::PruneAggregationSchedulesWorker' +Settings.cron_jobs['container_expiration_policy_worker'] ||= Settingslogic.new({}) +Settings.cron_jobs['container_expiration_policy_worker']['cron'] ||= '50 * * * *' +Settings.cron_jobs['container_expiration_policy_worker']['job_class'] = 'ContainerExpirationPolicyWorker' Gitlab.ee do Settings.cron_jobs['adjourned_group_deletion_worker'] ||= Settingslogic.new({}) @@ -590,7 +594,7 @@ end # Backup # Settings['backup'] ||= Settingslogic.new({}) -Settings.backup['keep_time'] ||= 0 +Settings.backup['keep_time'] ||= 0 Settings.backup['pg_schema'] = nil Settings.backup['path'] = Settings.absolute(Settings.backup['path'] || "tmp/backups/") Settings.backup['archive_permissions'] ||= 0600 diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index 383fe6493ad..aa2601ea650 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -4,11 +4,11 @@ require 'prometheus/client' def prometheus_default_multiproc_dir return unless Rails.env.development? || Rails.env.test? - if Sidekiq.server? + if Gitlab::Runtime.sidekiq? Rails.root.join('tmp/prometheus_multiproc_dir/sidekiq') - elsif defined?(Unicorn::Worker) + elsif Gitlab::Runtime.unicorn? Rails.root.join('tmp/prometheus_multiproc_dir/unicorn') - elsif defined?(::Puma) + elsif Gitlab::Runtime.puma? Rails.root.join('tmp/prometheus_multiproc_dir/puma') else Rails.root.join('tmp/prometheus_multiproc_dir') @@ -51,9 +51,9 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? Gitlab::Cluster::LifecycleEvents.on_master_start do ::Prometheus::Client.reinitialize_on_pid_change(force: true) - if defined?(::Unicorn) + if Gitlab::Runtime.unicorn? Gitlab::Metrics::Samplers::UnicornSampler.instance(Settings.monitoring.unicorn_sampler_interval).start - elsif defined?(::Puma) + elsif Gitlab::Runtime.puma? Gitlab::Metrics::Samplers::PumaSampler.instance(Settings.monitoring.puma_sampler_interval).start end @@ -64,7 +64,7 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? end end -if defined?(::Unicorn) || defined?(::Puma) +if Gitlab::Runtime.web_server? Gitlab::Cluster::LifecycleEvents.on_master_start do Gitlab::Metrics::Exporter::WebExporter.instance.start end diff --git a/config/initializers/8_devise.rb b/config/initializers/8_devise.rb index 8d4c5fa382c..e1c37caaafd 100644 --- a/config/initializers/8_devise.rb +++ b/config/initializers/8_devise.rb @@ -203,7 +203,7 @@ Devise.setup do |config| config.navigational_formats = [:"*/*", "*/*", :html, :zip] # The default HTTP method used to sign out a resource. Default is :delete. - config.sign_out_via = :get + config.sign_out_via = :post # ==> OmniAuth # To configure a new OmniAuth provider copy and edit omniauth.rb.sample diff --git a/config/initializers/action_dispatch_journey_formatter.rb b/config/initializers/action_dispatch_journey_formatter.rb new file mode 100644 index 00000000000..93cf407c73c --- /dev/null +++ b/config/initializers/action_dispatch_journey_formatter.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# TODO: Eliminate this file when https://github.com/rails/rails/pull/38184 is released. +# Cleanup issue: https://gitlab.com/gitlab-org/gitlab/issues/195841 +ActionDispatch::Journey::Formatter.prepend(Gitlab::Patch::ActionDispatchJourneyFormatter) + +module ActionDispatch + module Journey + module Path + class Pattern + def requirements_for_missing_keys_check + @requirements_for_missing_keys_check ||= requirements.each_with_object({}) do |(key, regex), hash| + hash[key] = /\A#{regex}\Z/ + end + end + end + end + end +end diff --git a/config/initializers/active_record_lifecycle.rb b/config/initializers/active_record_lifecycle.rb index 61f1d299960..2cf0f0439a9 100644 --- a/config/initializers/active_record_lifecycle.rb +++ b/config/initializers/active_record_lifecycle.rb @@ -2,7 +2,7 @@ # Don't handle sidekiq configuration as it # has its own special active record configuration here -if defined?(ActiveRecord::Base) && !Sidekiq.server? +if defined?(ActiveRecord::Base) && !Gitlab::Runtime.sidekiq? Gitlab::Cluster::LifecycleEvents.on_worker_start do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.establish_connection diff --git a/config/initializers/cluster_events_before_phased_restart.rb b/config/initializers/cluster_events_before_phased_restart.rb index cbb1dd1a53a..aae5470d6ae 100644 --- a/config/initializers/cluster_events_before_phased_restart.rb +++ b/config/initializers/cluster_events_before_phased_restart.rb @@ -5,10 +5,8 @@ # # Follow-up the issue: https://gitlab.com/gitlab-org/gitlab/issues/34107 -if defined?(::Puma) +if Gitlab::Runtime.puma? Puma::Cluster.prepend(::Gitlab::Cluster::Mixins::PumaCluster) -end - -if defined?(::Unicorn::HttpServer) +elsif Gitlab::Runtime.unicorn? Unicorn::HttpServer.prepend(::Gitlab::Cluster::Mixins::UnicornHttpServer) end diff --git a/config/initializers/correlation_id.rb b/config/initializers/correlation_id.rb deleted file mode 100644 index 2a7c138dc40..00000000000 --- a/config/initializers/correlation_id.rb +++ /dev/null @@ -1,3 +0,0 @@ -# frozen_string_literal: true - -Rails.application.config.middleware.use(Gitlab::Middleware::CorrelationId) diff --git a/config/initializers/database_config.rb b/config/initializers/database_config.rb index d8c2821066b..b5490fc4719 100644 --- a/config/initializers/database_config.rb +++ b/config/initializers/database_config.rb @@ -1,18 +1,40 @@ # frozen_string_literal: true -# when running on puma, scale connection pool size with the number -# of threads per worker process -if defined?(::Puma) +def log_pool_size(db, previous_pool_size, current_pool_size) + log_message = ["#{db} connection pool size: #{current_pool_size}"] + + if previous_pool_size && current_pool_size > previous_pool_size + log_message << "(increased from #{previous_pool_size} to match thread count)" + end + + Gitlab::AppLogger.debug(log_message.join(' ')) +end + +# When running on multi-threaded runtimes like Puma or Sidekiq, +# set the number of threads per process as the minimum DB connection pool size. +# This is to avoid connectivity issues as was documented here: +# https://github.com/rails/rails/pull/23057 +if Gitlab::Runtime.multi_threaded? + max_threads = Gitlab::Runtime.max_threads db_config = Gitlab::Database.config || Rails.application.config.database_configuration[Rails.env] - puma_options = Puma.cli_config.options + previous_db_pool_size = db_config['pool'] - # We use either the maximum number of threads per worker process, or - # the user specified value, whichever is larger. - desired_pool_size = [db_config['pool'].to_i, puma_options[:max_threads]].max + db_config['pool'] = [db_config['pool'].to_i, max_threads].max - db_config['pool'] = desired_pool_size - - # recreate the connection pool from the new config ActiveRecord::Base.establish_connection(db_config) + + current_db_pool_size = ActiveRecord::Base.connection.pool.size + + log_pool_size('DB', previous_db_pool_size, current_db_pool_size) + + Gitlab.ee do + if Gitlab::Runtime.sidekiq? && Gitlab::Geo.geo_database_configured? + previous_geo_db_pool_size = Rails.configuration.geo_database['pool'] + Rails.configuration.geo_database['pool'] = max_threads + Geo::TrackingBase.establish_connection(Rails.configuration.geo_database) + current_geo_db_pool_size = Geo::TrackingBase.connection_pool.size + log_pool_size('Geo DB', previous_geo_db_pool_size, current_geo_db_pool_size) + end + end end diff --git a/config/initializers/elastic_client_setup.rb b/config/initializers/elastic_client_setup.rb index f38b606b3a8..21745bd81d8 100644 --- a/config/initializers/elastic_client_setup.rb +++ b/config/initializers/elastic_client_setup.rb @@ -18,6 +18,32 @@ Gitlab.ee do Elasticsearch::Model::ClassMethods.prepend GemExtensions::Elasticsearch::Model::Client Elasticsearch::Model.singleton_class.prepend GemExtensions::Elasticsearch::Model::Client + # This monkey patch cannot be handled by prepend like the above since this + # module is included into other classes. + module Elasticsearch + module Model + module Response + module Base + if Gem::Version.new(Elasticsearch::Model::VERSION) >= Gem::Version.new('7.0.0') + raise "elasticsearch-model was upgraded, please remove this monkey patch in #{__FILE__}" + end + + # Handle ES7 API where total is returned as an object. This + # change is taken from the V7 gem + # https://github.com/elastic/elasticsearch-rails/commit/9c40f630e1b549f0b7889fe33dcd826b485af6fc + # and can be removed when we upgrade the gem to V7 + def total + if response.response['hits']['total'].respond_to?(:keys) + response.response['hits']['total']['value'] + else + response.response['hits']['total'] + end + end + end + end + end + end + ### Modified from elasticsearch-model/lib/elasticsearch/model.rb [ diff --git a/config/initializers/labkit_middleware.rb b/config/initializers/labkit_middleware.rb new file mode 100644 index 00000000000..ea4103f052f --- /dev/null +++ b/config/initializers/labkit_middleware.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +Rails.application.config.middleware.use(Labkit::Middleware::Rack) diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index a8207862739..dc064a76033 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -1,5 +1,5 @@ # Only use Lograge for Rails -unless Sidekiq.server? +unless Gitlab::Runtime.sidekiq? filename = File.join(Rails.root, 'log', "#{Rails.env}_json.log") Rails.application.configure do @@ -37,7 +37,7 @@ unless Sidekiq.server? payload[:response] = event.payload[:response] if event.payload[:response] payload[Labkit::Correlation::CorrelationId::LOG_KEY] = Labkit::Correlation::CorrelationId.current_id - if cpu_s = Gitlab::Metrics::System.thread_cpu_duration(::Gitlab::RequestContext.start_thread_cpu_time) + if cpu_s = Gitlab::Metrics::System.thread_cpu_duration(::Gitlab::RequestContext.instance.start_thread_cpu_time) payload[:cpu_s] = cpu_s end diff --git a/config/initializers/postgresql_limit_fix.rb b/config/initializers/postgresql_limit_fix.rb deleted file mode 100644 index 4224d857e8a..00000000000 --- a/config/initializers/postgresql_limit_fix.rb +++ /dev/null @@ -1,27 +0,0 @@ -if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) - class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter - module LimitFilter - def add_column(table_name, column_name, type, options = {}) - options.delete(:limit) if type == :text - super(table_name, column_name, type, options) - end - - def change_column(table_name, column_name, type, options = {}) - options.delete(:limit) if type == :text - super(table_name, column_name, type, options) - end - end - - prepend ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::LimitFilter - - class TableDefinition - def text(*args) - options = args.extract_options! - options.delete(:limit) - column_names = args - type = :text - column_names.each { |name| column(name, type, options) } - end - end - end -end diff --git a/config/initializers/rack_timeout.rb b/config/initializers/rack_timeout.rb index 246cf3482a4..1f1264de208 100644 --- a/config/initializers/rack_timeout.rb +++ b/config/initializers/rack_timeout.rb @@ -9,7 +9,7 @@ # and it's used only as the last resort. In such case this termination is # logged and we should fix the potential timeout issue in the code itself. -if defined?(::Puma) && !Rails.env.test? +if Gitlab::Runtime.puma? && !Rails.env.test? require 'rack/timeout/base' Gitlab::Application.configure do |config| diff --git a/config/initializers/request_context.rb b/config/initializers/request_context.rb index 0b485fc1adc..f79f1f32d70 100644 --- a/config/initializers/request_context.rb +++ b/config/initializers/request_context.rb @@ -1,3 +1,3 @@ Rails.application.configure do |config| - config.middleware.insert_after RequestStore::Middleware, Gitlab::RequestContext + config.middleware.insert_after RequestStore::Middleware, Gitlab::Middleware::RequestContext end diff --git a/config/initializers/retriable.rb b/config/initializers/retriable.rb new file mode 100644 index 00000000000..3c673cc7513 --- /dev/null +++ b/config/initializers/retriable.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +Retriable.configure do |config| + config.contexts[:relation_import] = { + tries: ENV.fetch('RELATION_IMPORT_TRIES', 3).to_i, + base_interval: ENV.fetch('RELATION_IMPORT_BASE_INTERVAL', 0.5).to_f, + multiplier: ENV.fetch('RELATION_IMPORT_MULTIPLIER', 1.5).to_f, + rand_factor: ENV.fetch('RELATION_IMPORT_RAND_FACTOR', 0.5).to_f, + on: Gitlab::ImportExport::ImportFailureService::RETRIABLE_EXCEPTIONS + } +end diff --git a/config/initializers/rspec_profiling.rb b/config/initializers/rspec_profiling.rb index 715e17057e0..9f29e48a63e 100644 --- a/config/initializers/rspec_profiling.rb +++ b/config/initializers/rspec_profiling.rb @@ -60,6 +60,9 @@ RspecProfiling.configure do |config| RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git) RspecProfiling::Run.prepend(RspecProfilingExt::Run) config.collector = RspecProfilingExt::Collectors::CSVWithTimestamps - config.csv_path = -> { "rspec_profiling/#{Time.now.to_i}-#{SecureRandom.hex(8)}-rspec-data.csv" } + config.csv_path = -> do + prefix = "#{ENV['CI_JOB_NAME']}-".tr(' ', '-') if ENV['CI_JOB_NAME'] + "rspec_profiling/#{prefix}#{Time.now.to_i}-#{SecureRandom.hex(8)}-rspec-data.csv" + end end end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index b4a1e0da41a..b90a04a19e1 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -88,23 +88,10 @@ Sidekiq.configure_server do |config| Gitlab::SidekiqVersioning.install! - db_config = Gitlab::Database.config || - Rails.application.config.database_configuration[Rails.env] - db_config['pool'] = Sidekiq.options[:concurrency] - ActiveRecord::Base.establish_connection(db_config) - Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") # rubocop:disable Gitlab/RailsLogger - Gitlab.ee do Gitlab::Mirror.configure_cron_job! Gitlab::Geo.configure_cron_jobs! - - if Gitlab::Geo.geo_database_configured? - Rails.configuration.geo_database['pool'] = Sidekiq.options[:concurrency] - Geo::TrackingBase.establish_connection(Rails.configuration.geo_database) - - Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{Geo::TrackingBase.connection_pool.size} (Geo tracking database)") # rubocop:disable Gitlab/RailsLogger - end end # Avoid autoload issue such as 'Mail::Parsers::AddressStruct' diff --git a/config/initializers/tracing.rb b/config/initializers/tracing.rb index 5b55a06692e..aaf74eb4cd3 100644 --- a/config/initializers/tracing.rb +++ b/config/initializers/tracing.rb @@ -2,7 +2,7 @@ if Labkit::Tracing.enabled? Rails.application.configure do |config| - config.middleware.insert_after Gitlab::Middleware::CorrelationId, ::Labkit::Tracing::RackMiddleware + config.middleware.insert_after Labkit::Middleware::Rack, ::Labkit::Tracing::RackMiddleware end # Instrument the Sidekiq client @@ -13,7 +13,7 @@ if Labkit::Tracing.enabled? end # Instrument Sidekiq server calls when running Sidekiq server - if Sidekiq.server? + if Gitlab::Runtime.sidekiq? Sidekiq.configure_server do |config| config.server_middleware do |chain| chain.add Labkit::Tracing::Sidekiq::ServerMiddleware diff --git a/config/initializers/validate_puma.rb b/config/initializers/validate_puma.rb index 64bd6e7bbc1..5abcfbfe6be 100644 --- a/config/initializers/validate_puma.rb +++ b/config/initializers/validate_puma.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -if defined?(::Puma) && ::Puma.cli_config.options[:workers].to_i.zero? +if Gitlab::Runtime.puma? && ::Puma.cli_config.options[:workers].to_i.zero? raise 'Puma is only supported in Cluster-mode: workers > 0' end diff --git a/config/locales/en.yml b/config/locales/en.yml index 950529f0355..dabcefba169 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -195,6 +195,8 @@ en: wrong_length: one: is the wrong length (should be 1 character) other: is the wrong length (should be %{count} characters) + search_chars_too_long: Search query is too long (maximum is %{count} characters) + search_terms_too_long: Search query is too long (maximum is %{count} terms) other_than: must be other than %{count} template: body: 'There were problems with the following fields:' diff --git a/config/routes/admin.rb b/config/routes/admin.rb index 9238eae3a8e..f363823f80c 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -24,7 +24,7 @@ namespace :admin do end resource :session, only: [:new, :create] do - get 'destroy', action: :destroy, as: :destroy + post 'destroy', action: :destroy, as: :destroy end resource :impersonation, only: :destroy @@ -45,7 +45,6 @@ namespace :admin do scope(path: 'groups/*id', controller: :groups, constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }) do - scope(as: :group) do put :members_update get :edit, action: :edit @@ -90,7 +89,6 @@ namespace :admin do path: '/', constraints: { id: Gitlab::PathRegex.project_route_regex }, only: [:show, :destroy]) do - member do put :transfer post :repository_check @@ -118,6 +116,11 @@ namespace :admin do put :clear_repository_check_states match :general, :integrations, :repository, :ci_cd, :reporting, :metrics_and_profiling, :network, :preferences, via: [:get, :patch] get :lets_encrypt_terms_of_service + + post :create_self_monitoring_project + get :status_create_self_monitoring_project + delete :delete_self_monitoring_project + get :status_delete_self_monitoring_project end resources :labels diff --git a/config/routes/group.rb b/config/routes/group.rb index 30671d4e0a1..24957d5ecef 100644 --- a/config/routes/group.rb +++ b/config/routes/group.rb @@ -68,7 +68,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do resources :uploads, only: [:create] do collection do - get ":secret/:filename", action: :show, as: :show, constraints: { filename: %r{[^/]+} } + get ":secret/:filename", action: :show, as: :show, constraints: { filename: %r{[^/]+} }, format: false, defaults: { format: nil } post :authorize end end diff --git a/config/routes/merge_requests.rb b/config/routes/merge_requests.rb new file mode 100644 index 00000000000..fd80c21deb1 --- /dev/null +++ b/config/routes/merge_requests.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do + member do + get :show # Insert this first to ensure redirections using merge_requests#show match this route + get :commit_change_content + post :merge + post :cancel_auto_merge + get :pipeline_status + get :ci_environments_status + post :toggle_subscription + post :remove_wip + post :assign_related_issues + get :discussions, format: :json + post :rebase + get :test_reports + get :exposed_artifacts + + scope constraints: ->(req) { req.format == :json }, as: :json do + get :commits + get :pipelines + get :diffs, to: 'merge_requests/diffs#show' + get :diffs_batch, to: 'merge_requests/diffs#diffs_batch' + get :diffs_metadata, to: 'merge_requests/diffs#diffs_metadata' + get :widget, to: 'merge_requests/content#widget' + get :cached_widget, to: 'merge_requests/content#cached_widget' + end + + scope action: :show do + get :commits, defaults: { tab: 'commits' } + get :pipelines, defaults: { tab: 'pipelines' } + get :diffs, defaults: { tab: 'diffs' } + end + + get :diff_for_path, controller: 'merge_requests/diffs' + + scope controller: 'merge_requests/conflicts' do + get :conflicts, action: :show + get :conflict_for_path + post :resolve_conflicts + end + end + + collection do + get :diff_for_path + post :bulk_update + end + + resources :discussions, only: [:show], constraints: { id: /\h{40}/ } do + member do + post :resolve + delete :resolve, action: :unresolve + end + end +end + +scope path: 'merge_requests', controller: 'merge_requests/creations' do + post '', action: :create, as: nil + + scope path: 'new', as: :new_merge_request do + get '', action: :new + + scope constraints: ->(req) { req.format == :json }, as: :json do + get :diffs + get :pipelines + end + + scope action: :new do + get :diffs, defaults: { tab: 'diffs' } + get :pipelines, defaults: { tab: 'pipelines' } + end + + get :diff_for_path + get :branch_from + get :branch_to + end +end diff --git a/config/routes/project.rb b/config/routes/project.rb index 26808de5b41..09e6b733bff 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -29,7 +29,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do constraints: { project_id: Gitlab::PathRegex.project_route_regex }, module: :projects, as: :project) do - # Begin of the /-/ scope. # Use this scope for all new project routes. scope '-' do @@ -58,6 +57,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do get :trace, defaults: { format: 'json' } get :raw get :terminal + + # This route is also defined in gitlab-workhorse. Make sure to update accordingly. get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', format: false end @@ -235,11 +236,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do get :metrics get :additional_metrics get :metrics_dashboard + + # This route is also defined in gitlab-workhorse. Make sure to update accordingly. get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', format: false get '/prometheus/api/v1/*proxy_path', to: 'environments/prometheus_api#proxy', as: :prometheus_api - get '/sample_metrics', to: 'environments/sample_metrics#query' if ENV['USE_SAMPLE_METRICS'] + get '/sample_metrics', to: 'environments/sample_metrics#query' end collection do @@ -256,20 +259,31 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end + namespace :performance_monitoring do + resources :dashboards, only: [:create] + end + + namespace :error_tracking do + resources :projects, only: :index + end + resources :error_tracking, only: [:index], controller: :error_tracking do collection do get ':issue_id/details', to: 'error_tracking#details', as: 'details' get ':issue_id/stack_trace', - to: 'error_tracking#stack_trace', + to: 'error_tracking/stack_traces#index', as: 'stack_trace' - post :list_projects + put ':issue_id', + to: 'error_tracking#update', + as: 'update' end end - # The wiki routing contains wildcard characters so + # The wiki and repository routing contains wildcard characters so # its preferable to keep it below all other project routes + draw :repository_scoped draw :wiki end # End of the /-/ scope. @@ -325,83 +339,18 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do end end - resources :merge_requests, concerns: :awardable, except: [:new, :create, :show], constraints: { id: /\d+/ } do - member do - get :show # Insert this first to ensure redirections using merge_requests#show match this route - get :commit_change_content - post :merge - post :cancel_auto_merge - get :pipeline_status - get :ci_environments_status - post :toggle_subscription - post :remove_wip - post :assign_related_issues - get :discussions, format: :json - post :rebase - get :test_reports - get :exposed_artifacts - - scope constraints: ->(req) { req.format == :json }, as: :json do - get :commits - get :pipelines - get :diffs, to: 'merge_requests/diffs#show' - get :diffs_batch, to: 'merge_requests/diffs#diffs_batch' - get :diffs_metadata, to: 'merge_requests/diffs#diffs_metadata' - get :widget, to: 'merge_requests/content#widget' - get :cached_widget, to: 'merge_requests/content#cached_widget' - end - - scope action: :show do - get :commits, defaults: { tab: 'commits' } - get :pipelines, defaults: { tab: 'pipelines' } - get :diffs, defaults: { tab: 'diffs' } - end + # Unscoped route. It will be replaced with redirect to /-/merge_requests/ + # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 + draw :merge_requests - get :diff_for_path, controller: 'merge_requests/diffs' - - scope controller: 'merge_requests/conflicts' do - get :conflicts, action: :show - get :conflict_for_path - post :resolve_conflicts - end - end - - collection do - get :diff_for_path - post :bulk_update - end - - resources :discussions, only: [:show], constraints: { id: /\h{40}/ } do - member do - post :resolve - delete :resolve, action: :unresolve - end - end - end - - scope path: 'merge_requests', controller: 'merge_requests/creations' do - post '', action: :create, as: nil - - scope path: 'new', as: :new_merge_request do - get '', action: :new - - scope constraints: ->(req) { req.format == :json }, as: :json do - get :diffs - get :pipelines - end - - scope action: :new do - get :diffs, defaults: { tab: 'diffs' } - get :pipelines, defaults: { tab: 'pipelines' } - end - - get :diff_for_path - get :branch_from - get :branch_to - end + # To ensure an old unscoped routing is used for the UI we need to + # add prefix 'as' to the scope routing and place it below original MR routing. + # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 + scope '-', as: 'scoped' do + draw :merge_requests end - resources :pipelines, only: [:index, :new, :create, :show] do + resources :pipelines, only: [:index, :new, :create, :show, :destroy] do collection do resource :pipelines_settings, path: 'settings', only: [:show, :update] get :charts @@ -503,7 +452,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resources :uploads, only: [:create] do collection do - get ":secret/:filename", action: :show, as: :show, constraints: { filename: %r{[^/]+} } + get ":secret/:filename", action: :show, as: :show, constraints: { filename: %r{[^/]+} }, format: false, defaults: { format: nil } post :authorize end end @@ -540,6 +489,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do # its preferable to keep it below all other project routes draw :repository + # To ensure an old unscoped routing is used for the UI we need to + # add prefix 'as' to the scope routing and place it below original routing. + # Issue https://gitlab.com/gitlab-org/gitlab/issues/118849 + scope '-', as: 'scoped' do + draw :repository + end + # All new routes should go under /-/ scope. # Look for scope '-' at the top of the file. # rubocop: enable Cop/PutProjectRoutesUnderScope diff --git a/config/routes/repository.rb b/config/routes/repository.rb index 4815575ba9f..d4805b67a5c 100644 --- a/config/routes/repository.rb +++ b/config/routes/repository.rb @@ -39,32 +39,6 @@ scope format: false do end end - scope path: '-', constraints: { id: Gitlab::PathRegex.git_reference_regex } do - resources :network, only: [:show] - - resources :graphs, only: [:show] do - member do - get :charts - get :commits - get :ci - get :languages - end - end - - get '/branches/:state', to: 'branches#index', as: :branches_filtered, constraints: { state: /active|stale|all/ } - resources :branches, only: [:index, :new, :create, :destroy] do - get :diverging_commit_counts, on: :collection - end - - delete :merged_branches, controller: 'branches', action: :destroy_all_merged - resources :tags, only: [:index, :show, :new, :create, :destroy] do - resource :release, controller: 'tags/releases', only: [:edit, :update] - end - - resources :protected_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex } - resources :protected_tags, only: [:index, :show, :create, :update, :destroy] - end - scope constraints: { id: /[^\0]+/ } do scope controller: :blob do get '/new/*id', action: :new, as: :new_blob diff --git a/config/routes/repository_scoped.rb b/config/routes/repository_scoped.rb new file mode 100644 index 00000000000..c6343039d62 --- /dev/null +++ b/config/routes/repository_scoped.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# All routing related to repository browsing +# that is already under /-/ scope only + +# Don't use format parameter as file extension (old 3.0.x behavior) +# See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments +scope format: false do + scope constraints: { id: Gitlab::PathRegex.git_reference_regex } do + resources :network, only: [:show] + + resources :graphs, only: [:show] do + member do + get :charts + get :commits + get :ci + get :languages + end + end + + get '/branches/:state', to: 'branches#index', as: :branches_filtered, constraints: { state: /active|stale|all/ } + resources :branches, only: [:index, :new, :create, :destroy] do + get :diverging_commit_counts, on: :collection + end + + delete :merged_branches, controller: 'branches', action: :destroy_all_merged + resources :tags, only: [:index, :show, :new, :create, :destroy] do + resource :release, controller: 'tags/releases', only: [:edit, :update] + end + + resources :protected_branches, only: [:index, :show, :create, :update, :destroy, :patch], constraints: { id: Gitlab::PathRegex.git_reference_regex } + resources :protected_tags, only: [:index, :show, :create, :update, :destroy] + end +end diff --git a/config/routes/uploads.rb b/config/routes/uploads.rb index 096ef146e07..fb8af76397c 100644 --- a/config/routes/uploads.rb +++ b/config/routes/uploads.rb @@ -21,9 +21,11 @@ scope path: :uploads do as: 'appearance_upload' # Project markdown uploads + # DEPRECATED: Remove this in GitLab 13.0 because this is redundant to show_namespace_project_uploads + # https://gitlab.com/gitlab-org/gitlab/issues/196396 get ":namespace_id/:project_id/:secret/:filename", - to: "projects/uploads#show", - constraints: { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: %r{[^/]+} } + to: redirect("%{namespace_id}/%{project_id}/uploads/%{secret}/%{filename}"), + constraints: { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: %r{[^/]+} }, format: false, defaults: { format: nil } # create uploads for models, snippets (notes) available for now post ':model', diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 68ad819d48b..2986431f21b 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -76,7 +76,7 @@ - [pages_domain_ssl_renewal, 1] - [object_storage_upload, 1] - [object_storage, 1] - - [plugin, 1] + - [file_hook, 1] - [pipeline_background, 1] - [repository_update_remote_mirror, 1] - [repository_remove_remote, 1] @@ -99,6 +99,8 @@ - [chaos, 2] - [create_evidence, 2] - [group_export, 1] + - [self_monitoring_project_create, 2] + - [self_monitoring_project_delete, 2] # EE-specific queues - [analytics, 1] @@ -116,6 +118,7 @@ - [elastic_full_index, 1] - [elastic_commit_indexer, 1] - [elastic_namespace_indexer, 1] + - [elastic_namespace_rollout, 1] - [export_csv, 1] - [incident_management, 2] - [jira_connect, 1] diff --git a/config/webpack.config.js b/config/webpack.config.js index d85fa84c32f..7da7e571d67 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -201,7 +201,7 @@ module.exports = { loader: 'raw-loader', }, { - test: /\.(gif|png)$/, + test: /\.(gif|png|mp4)$/, loader: 'url-loader', options: { limit: 2048 }, }, |