From 36a59d088eca61b834191dacea009677a96c052f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 19 May 2022 07:33:21 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-0-stable-ee --- lib/tasks/dev.rake | 15 +++++++++++++++ lib/tasks/gitlab/db.rake | 11 ++++++++++- lib/tasks/gitlab/db/validate_config.rake | 4 +++- lib/tasks/gitlab/metrics_exporter.rake | 26 ++++++++++++++++++++++++++ lib/tasks/gitlab/seed/group_seed.rake | 2 +- lib/tasks/gitlab/shell.rake | 1 - lib/tasks/gitlab/tw/codeowners.rake | 23 +++++++++++------------ lib/tasks/gitlab/update_templates.rake | 2 +- lib/tasks/haml-lint.rake | 1 - 9 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 lib/tasks/gitlab/metrics_exporter.rake (limited to 'lib/tasks') diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 42b12cd0ae3..08a11100431 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -58,9 +58,13 @@ namespace :dev do namespace :copy_db do ALLOWED_DATABASES = %w[ci].freeze + defined_copy_db_tasks = [] + ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name| next unless ALLOWED_DATABASES.include?(name) + defined_copy_db_tasks << name + desc "Copies the #{name} database from the main database" task name => :environment do Rake::Task["dev:terminate_all_connections"].invoke @@ -72,5 +76,16 @@ namespace :dev do warn "Database '#{db_config.database}' already exists" end end + + ALLOWED_DATABASES.each do |name| + next if defined_copy_db_tasks.include?(name) + + # :nocov: we cannot mock ActiveRecord::Tasks::DatabaseTasks in time + # Workaround for GDK issue, see + # https://gitlab.com/gitlab-org/gitlab-development-kit/-/issues/1464 + desc "No-op task" + task name + # :nocov: + end end end diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 3a7e53a27e4..068dc463d16 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -282,7 +282,7 @@ namespace :gitlab do puts "There are #{Gitlab::Database::Reindexing::QueuedAction.queued.size} queued actions in total." end - unless Feature.enabled?(:database_reindexing, type: :ops, default_enabled: :yaml) + unless Feature.enabled?(:database_reindexing, type: :ops) puts <<~NOTE.color(:yellow) Note: database_reindexing feature is currently disabled. @@ -328,6 +328,15 @@ namespace :gitlab do Gitlab::Database::Migrations::Runner.background_migrations.run_jobs(for_duration: duration) end + + desc 'Sample batched background migrations with instrumentation' + task :sample_batched_background_migrations, [:database, :duration_s] => [:environment] do |_t, args| + database_name = args[:database] || 'main' + duration = args[:duration_s]&.to_i&.seconds || 30.minutes # Default of 30 minutes + + Gitlab::Database::Migrations::Runner.batched_background_migrations(for_database: database_name) + .run_jobs(for_duration: duration) + end end desc 'Run all pending batched migrations' diff --git a/lib/tasks/gitlab/db/validate_config.rake b/lib/tasks/gitlab/db/validate_config.rake index cc5f6bb6e09..66aa949cc94 100644 --- a/lib/tasks/gitlab/db/validate_config.rake +++ b/lib/tasks/gitlab/db/validate_config.rake @@ -6,7 +6,7 @@ namespace :gitlab do namespace :db do desc 'Validates `config/database.yml` to ensure a correct behavior is configured' task validate_config: :environment do - original_db_config = ActiveRecord::Base.connection_db_config + original_db_config = ActiveRecord::Base.connection_db_config # rubocop:disable Database/MultipleDatabases # The include_replicas: is a legacy name to fetch all hidden entries (replica: true or database_tasks: false) # Once we upgrade to Rails 7.x this should be changed to `include_hidden: true` @@ -15,6 +15,7 @@ namespace :gitlab do db_configs = db_configs.reject(&:replica?) # Map each database connection into unique identifier of system+database + # rubocop:disable Database/MultipleDatabases all_connections = db_configs.map do |db_config| identifier = begin @@ -32,6 +33,7 @@ namespace :gitlab do identifier: identifier } end.compact + # rubocop:enable Database/MultipleDatabases unique_connections = all_connections.group_by { |connection| connection[:identifier] } primary_connection = all_connections.find { |connection| ActiveRecord::Base.configurations.primary?(connection[:name]) } diff --git a/lib/tasks/gitlab/metrics_exporter.rake b/lib/tasks/gitlab/metrics_exporter.rake new file mode 100644 index 00000000000..d9dd80b8eeb --- /dev/null +++ b/lib/tasks/gitlab/metrics_exporter.rake @@ -0,0 +1,26 @@ +# frozen_string_literal: true +require_relative Rails.root.join('metrics_server', 'dependencies') +require_relative Rails.root.join('metrics_server', 'metrics_server') + +namespace :gitlab do + namespace :metrics_exporter do + REPO = 'https://gitlab.com/gitlab-org/gitlab-metrics-exporter.git' + + desc "GitLab | Metrics Exporter | Install or upgrade gitlab-metrics-exporter" + task :install, [:dir] => :gitlab_environment do |t, args| + unless args.dir.present? + abort %(Please specify the directory where you want to install the exporter +Usage: rake "gitlab:metrics_exporter:install[/installation/dir]") + end + + version = ENV['GITLAB_METRICS_EXPORTER_VERSION'] || MetricsServer.version + make = Gitlab::Utils.which('gmake') || Gitlab::Utils.which('make') + + abort "Couldn't find a 'make' binary" unless make + + checkout_or_clone_version(version: version, repo: REPO, target_dir: args.dir, clone_opts: %w[--depth 1]) + + Dir.chdir(args.dir) { run_command!([make]) } + end + end +end diff --git a/lib/tasks/gitlab/seed/group_seed.rake b/lib/tasks/gitlab/seed/group_seed.rake index a9a350fb6c3..4f5df7841e2 100644 --- a/lib/tasks/gitlab/seed/group_seed.rake +++ b/lib/tasks/gitlab/seed/group_seed.rake @@ -158,7 +158,7 @@ class GroupSeeder group = Group.find(group_id) label_title = FFaker::Product.brand - Labels::CreateService.new(title: label_title, color: "##{Digest::MD5.hexdigest(label_title)[0..5]}").execute(group: group) + Labels::CreateService.new(title: label_title, color: "#{::Gitlab::Color.color_for(label_title)}").execute(group: group) end end end diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index b3abc48f8e0..8627a326247 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -21,7 +21,6 @@ namespace :gitlab do config = { user: Gitlab.config.gitlab.user, gitlab_url: gitlab_url, - http_settings: { self_signed_cert: false }.stringify_keys, auth_file: File.join(user_home, ".ssh", "authorized_keys"), log_level: "INFO", audit_usernames: false diff --git a/lib/tasks/gitlab/tw/codeowners.rake b/lib/tasks/gitlab/tw/codeowners.rake index 0aed017c84a..6574bfd2549 100644 --- a/lib/tasks/gitlab/tw/codeowners.rake +++ b/lib/tasks/gitlab/tw/codeowners.rake @@ -17,16 +17,16 @@ namespace :tw do CodeOwnerRule.new('Code Review', '@aqualls'), CodeOwnerRule.new('Compliance', '@eread'), CodeOwnerRule.new('Composition Analysis', '@rdickenson'), - CodeOwnerRule.new('Configure', '@marcia'), + CodeOwnerRule.new('Configure', '@sselhorn'), CodeOwnerRule.new('Container Security', '@claytoncornell'), CodeOwnerRule.new('Contributor Experience', '@eread'), CodeOwnerRule.new('Conversion', '@kpaizee'), - CodeOwnerRule.new('Database', '@marcia'), - CodeOwnerRule.new('Development', '@marcia'), + CodeOwnerRule.new('Database', '@aqualls'), + CodeOwnerRule.new('Development', '@sselhorn'), CodeOwnerRule.new('Distribution', '@axil'), CodeOwnerRule.new('Distribution (Charts)', '@axil'), CodeOwnerRule.new('Distribution (Omnibus)', '@axil'), - CodeOwnerRule.new('Documentation Guidelines', '@cnorris'), + CodeOwnerRule.new('Documentation Guidelines', '@sselhorn'), CodeOwnerRule.new('Dynamic Analysis', '@rdickenson'), CodeOwnerRule.new('Ecosystem', '@kpaizee'), CodeOwnerRule.new('Editor', '@aqualls'), @@ -35,13 +35,12 @@ namespace :tw do CodeOwnerRule.new('Fuzz Testing', '@rdickenson'), CodeOwnerRule.new('Geo', '@axil'), CodeOwnerRule.new('Gitaly', '@eread'), - CodeOwnerRule.new('Global Search', '@marcia'), + CodeOwnerRule.new('Global Search', '@sselhorn'), CodeOwnerRule.new('Import', '@eread'), - CodeOwnerRule.new('Infrastructure', '@marcia'), + CodeOwnerRule.new('Infrastructure', '@sselhorn'), CodeOwnerRule.new('Integrations', '@kpaizee'), CodeOwnerRule.new('Knowledge', '@aqualls'), - CodeOwnerRule.new('License', '@sselhorn'), - CodeOwnerRule.new('Memory', '@marcia'), + CodeOwnerRule.new('Memory', '@sselhorn'), CodeOwnerRule.new('Monitor', '@msedlakjakubowski'), CodeOwnerRule.new('Observability', 'msedlakjakubowski'), CodeOwnerRule.new('Optimize', '@fneill'), @@ -53,20 +52,20 @@ namespace :tw do CodeOwnerRule.new('Product Intelligence', '@claytoncornell'), CodeOwnerRule.new('Product Planning', '@msedlakjakubowski'), CodeOwnerRule.new('Project Management', '@msedlakjakubowski'), - CodeOwnerRule.new('Provision', '@sselhorn'), - CodeOwnerRule.new('Purchase', '@sselhorn'), + CodeOwnerRule.new('Provision', '@fneill'), + CodeOwnerRule.new('Purchase', '@fneill'), CodeOwnerRule.new('Redirect', 'Redirect'), CodeOwnerRule.new('Release', '@rdickenson'), CodeOwnerRule.new('Respond', '@msedlakjakubowski'), CodeOwnerRule.new('Runner', '@sselhorn'), - CodeOwnerRule.new('Sharding', '@marcia'), + CodeOwnerRule.new('Sharding', '@sselhorn'), CodeOwnerRule.new('Source Code', '@aqualls'), CodeOwnerRule.new('Static Analysis', '@rdickenson'), CodeOwnerRule.new('Static Site Editor', '@aqualls'), CodeOwnerRule.new('Style Guide', '@sselhorn'), CodeOwnerRule.new('Testing', '@eread'), CodeOwnerRule.new('Threat Insights', '@claytoncornell'), - CodeOwnerRule.new('Utilization', '@sselhorn'), + CodeOwnerRule.new('Utilization', '@fneill'), CodeOwnerRule.new('Vulnerability Research', '@claytoncornell'), CodeOwnerRule.new('Workspace', '@fneill') ].freeze diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index 247897bed0b..07dd5ebeacb 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -79,7 +79,7 @@ namespace :gitlab do Gitlab::TaskHelpers.run_command!(['tar', 'xf', 'archive.tar.gz']) extracted_project_basename = Dir['*/'].first Dir.chdir(extracted_project_basename) do - Gitlab::TaskHelpers.run_command!(%w(git init)) + Gitlab::TaskHelpers.run_command!(%w(git init --initial-branch=master)) Gitlab::TaskHelpers.run_command!(%w(git add .)) Gitlab::TaskHelpers.run_command!(['git', 'commit', '--author', 'GitLab ', '--message', commit_message]) diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake index 71e84d3795f..29589571344 100644 --- a/lib/tasks/haml-lint.rake +++ b/lib/tasks/haml-lint.rake @@ -2,7 +2,6 @@ unless Rails.env.production? require 'haml_lint/rake_task' - require Rails.root.join('haml_lint/inline_javascript') HamlLint::RakeTask.new end -- cgit v1.2.1