diff options
Diffstat (limited to 'lib/tasks/gitlab')
47 files changed, 265 insertions, 40 deletions
diff --git a/lib/tasks/gitlab/artifacts/check.rake b/lib/tasks/gitlab/artifacts/check.rake index a105261ed51..057bb17dbda 100644 --- a/lib/tasks/gitlab/artifacts/check.rake +++ b/lib/tasks/gitlab/artifacts/check.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :artifacts do desc 'GitLab | Artifacts | Check integrity of uploaded job artifacts' diff --git a/lib/tasks/gitlab/artifacts/migrate.rake b/lib/tasks/gitlab/artifacts/migrate.rake index 871fdfb4fde..94867e1a16a 100644 --- a/lib/tasks/gitlab/artifacts/migrate.rake +++ b/lib/tasks/gitlab/artifacts/migrate.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' require 'resolv-replace' diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index de2dfca8c1b..c53ef8382b8 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'active_record/fixtures' namespace :gitlab do diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake index 56cbbae1f67..df0c6a260a2 100644 --- a/lib/tasks/gitlab/bulk_add_permission.rake +++ b/lib/tasks/gitlab/bulk_add_permission.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :import do desc "GitLab | Import | Add all users to all projects (admin users are added as maintainers)" diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 9e60a585330..d4e38100609 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do desc 'GitLab | Check the configuration of GitLab and its environment' task check: :gitlab_environment do diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake index a56a0435673..6c3a7a77e0e 100644 --- a/lib/tasks/gitlab/cleanup.rake +++ b/lib/tasks/gitlab/cleanup.rake @@ -56,7 +56,7 @@ namespace :gitlab do task orphan_job_artifact_files: :gitlab_environment do warn_user_is_not_gitlab - cleaner = Gitlab::Cleanup::OrphanJobArtifactFiles.new(limit: limit, dry_run: dry_run?, niceness: niceness, logger: logger) + cleaner = Gitlab::Cleanup::OrphanJobArtifactFiles.new(dry_run: dry_run?, niceness: niceness, logger: logger) cleaner.run! if dry_run? @@ -78,8 +78,7 @@ namespace :gitlab do cleaner = Gitlab::Cleanup::OrphanLfsFileReferences.new( project, dry_run: dry_run?, - logger: logger, - limit: limit + logger: logger ) cleaner.run! @@ -162,10 +161,6 @@ namespace :gitlab do ENV['DEBUG'].present? end - def limit - ENV['LIMIT']&.to_i - end - def niceness ENV['NICENESS'].presence end diff --git a/lib/tasks/gitlab/container_registry.rake b/lib/tasks/gitlab/container_registry.rake index cd18c873a5a..086f99971bc 100644 --- a/lib/tasks/gitlab/container_registry.rake +++ b/lib/tasks/gitlab/container_registry.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :container_registry do desc "GitLab | Container Registry | Configure" diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 901e349ea31..541a4fc62af 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :db do desc 'GitLab | DB | Manually insert schema migration version' @@ -229,5 +231,37 @@ namespace :gitlab do puts "Found user created projects. Database active" exit 0 end + + desc 'Run migrations with instrumentation' + task :migration_testing, [:result_file] => :environment do |_, args| + result_file = args[:result_file] || raise("Please specify result_file argument") + raise "File exists already, won't overwrite: #{result_file}" if File.exist?(result_file) + + verbose_was, ActiveRecord::Migration.verbose = ActiveRecord::Migration.verbose, true + + ctx = ActiveRecord::Base.connection.migration_context + existing_versions = ctx.get_all_versions.to_set + + pending_migrations = ctx.migrations.reject do |migration| + existing_versions.include?(migration.version) + end + + instrumentation = Gitlab::Database::Migrations::Instrumentation.new + + pending_migrations.each do |migration| + instrumentation.observe(migration.version) do + ActiveRecord::Migrator.new(:up, ctx.migrations, ctx.schema_migration, migration.version).run + end + end + ensure + if instrumentation + File.open(result_file, 'wb+') do |io| + io << instrumentation.observations.to_json + end + end + + ActiveRecord::Base.clear_cache! + ActiveRecord::Migration.verbose = verbose_was + end end end diff --git a/lib/tasks/gitlab/doctor/secrets.rake b/lib/tasks/gitlab/doctor/secrets.rake index 3fdef9dfc80..6e3f474312c 100644 --- a/lib/tasks/gitlab/doctor/secrets.rake +++ b/lib/tasks/gitlab/doctor/secrets.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :doctor do desc "GitLab | Check if the database encrypted values can be decrypted using current secrets" diff --git a/lib/tasks/gitlab/exclusive_lease.rake b/lib/tasks/gitlab/exclusive_lease.rake index 63b06d5251a..bee9782f373 100644 --- a/lib/tasks/gitlab/exclusive_lease.rake +++ b/lib/tasks/gitlab/exclusive_lease.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :exclusive_lease do desc 'GitLab | Exclusive Lease | Clear existing exclusive leases for specified scope (default: *)' diff --git a/lib/tasks/gitlab/external_diffs.rake b/lib/tasks/gitlab/external_diffs.rake index 08f25914007..7a5fa07aed1 100644 --- a/lib/tasks/gitlab/external_diffs.rake +++ b/lib/tasks/gitlab/external_diffs.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :external_diffs do desc "Override external diffs in file storage to be in object storage instead. This does not change the actual location of the data" diff --git a/lib/tasks/gitlab/features.rake b/lib/tasks/gitlab/features.rake index 2309aa5d214..e44328e0de1 100644 --- a/lib/tasks/gitlab/features.rake +++ b/lib/tasks/gitlab/features.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :features do desc 'GitLab | Features | Enable direct Git access via Rugged for NFS' diff --git a/lib/tasks/gitlab/generate_sample_prometheus_data.rake b/lib/tasks/gitlab/generate_sample_prometheus_data.rake index 250eaaa5568..4cd75af9d00 100644 --- a/lib/tasks/gitlab/generate_sample_prometheus_data.rake +++ b/lib/tasks/gitlab/generate_sample_prometheus_data.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do desc "GitLab | Generate Sample Prometheus Data" task :generate_sample_prometheus_data, [:environment_id] => :gitlab_environment do |_, args| diff --git a/lib/tasks/gitlab/git.rake b/lib/tasks/gitlab/git.rake index abb15f29328..9c5549b4a54 100644 --- a/lib/tasks/gitlab/git.rake +++ b/lib/tasks/gitlab/git.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :git do desc 'GitLab | Git | Check all repos integrity' diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake index 49d2d3d62a2..9e474b00ba7 100644 --- a/lib/tasks/gitlab/gitaly.rake +++ b/lib/tasks/gitlab/gitaly.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :gitaly do desc 'GitLab | Gitaly | Install or upgrade gitaly' diff --git a/lib/tasks/gitlab/graphql.rake b/lib/tasks/gitlab/graphql.rake index f708114c226..e4eb4604138 100644 --- a/lib/tasks/gitlab/graphql.rake +++ b/lib/tasks/gitlab/graphql.rake @@ -33,7 +33,43 @@ namespace :gitlab do ) namespace :graphql do - desc 'Gitlab | GraphQL | Validate queries' + desc 'GitLab | GraphQL | Analyze queries' + task analyze: [:environment, :enable_feature_flags] do |t, args| + queries = if args.to_a.present? + args.to_a.flat_map { |path| Gitlab::Graphql::Queries.find(path) } + else + Gitlab::Graphql::Queries.all + end + + queries.each do |defn| + $stdout.puts defn.file + summary, errs = defn.validate(GitlabSchema) + + if summary == :client_query + $stdout.puts " - client query" + elsif errs.present? + $stdout.puts " - invalid query".color(:red) + else + complexity = defn.complexity(GitlabSchema) + color = case complexity + when 0..GitlabSchema::DEFAULT_MAX_COMPLEXITY + :green + when GitlabSchema::DEFAULT_MAX_COMPLEXITY..GitlabSchema::AUTHENTICATED_COMPLEXITY + :yellow + when GitlabSchema::AUTHENTICATED_COMPLEXITY..GitlabSchema::ADMIN_COMPLEXITY + :orange + else + :red + end + + $stdout.puts " - complexity: #{complexity}".color(color) + end + + $stdout.puts "" + end + end + + desc 'GitLab | GraphQL | Validate queries' task validate: [:environment, :enable_feature_flags] do |t, args| queries = if args.to_a.present? args.to_a.flat_map { |path| Gitlab::Graphql::Queries.find(path) } @@ -48,10 +84,10 @@ namespace :gitlab do when :client_query warn("SKIP #{defn.file}: client query") else - warn("OK #{defn.file}") if errs.empty? + warn("#{'OK'.color(:green)} #{defn.file}") if errs.empty? errs.each do |err| warn(<<~MSG) - ERROR #{defn.file}: #{err.message} (at #{err.path.join('.')}) + #{'ERROR'.color(:red)} #{defn.file}: #{err.message} (at #{err.path.join('.')}) MSG end end diff --git a/lib/tasks/gitlab/helpers.rake b/lib/tasks/gitlab/helpers.rake index 14d1125a03d..b61b1833c5a 100644 --- a/lib/tasks/gitlab/helpers.rake +++ b/lib/tasks/gitlab/helpers.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Prevent StateMachine warnings from outputting during a cron task StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON'] diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake index 701d40b7929..bf0ba40fb31 100644 --- a/lib/tasks/gitlab/import.rake +++ b/lib/tasks/gitlab/import.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :import do # How to use: diff --git a/lib/tasks/gitlab/import_export.rake b/lib/tasks/gitlab/import_export.rake index adf696350d7..72598cdf863 100644 --- a/lib/tasks/gitlab/import_export.rake +++ b/lib/tasks/gitlab/import_export.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :import_export do desc 'GitLab | Import/Export | Show Import/Export version' diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index d85c8fc7949..2826002bdc2 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :env do desc 'GitLab | Env | Show information about GitLab and its environment' diff --git a/lib/tasks/gitlab/ldap.rake b/lib/tasks/gitlab/ldap.rake index fe7920c621f..3b2834c0008 100644 --- a/lib/tasks/gitlab/ldap.rake +++ b/lib/tasks/gitlab/ldap.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :ldap do desc 'GitLab | LDAP | Rename provider' diff --git a/lib/tasks/gitlab/lfs/check.rake b/lib/tasks/gitlab/lfs/check.rake index 869463d4e5d..582b87337ae 100644 --- a/lib/tasks/gitlab/lfs/check.rake +++ b/lib/tasks/gitlab/lfs/check.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :lfs do desc 'GitLab | LFS | Check integrity of uploaded LFS objects' diff --git a/lib/tasks/gitlab/lfs/migrate.rake b/lib/tasks/gitlab/lfs/migrate.rake index 3d4c847a0f0..05249a126bc 100644 --- a/lib/tasks/gitlab/lfs/migrate.rake +++ b/lib/tasks/gitlab/lfs/migrate.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' desc "GitLab | LFS | Migrate LFS objects to remote storage" diff --git a/lib/tasks/gitlab/list_repos.rake b/lib/tasks/gitlab/list_repos.rake index b854c34a8e5..56ec94d2aef 100644 --- a/lib/tasks/gitlab/list_repos.rake +++ b/lib/tasks/gitlab/list_repos.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do task list_repos: :environment do scope = Project diff --git a/lib/tasks/gitlab/packages/events.rake b/lib/tasks/gitlab/packages/events.rake index cfe97984dda..4bf4ce430f1 100644 --- a/lib/tasks/gitlab/packages/events.rake +++ b/lib/tasks/gitlab/packages/events.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' desc "GitLab | Packages | Events | Generate hll counter events file for packages" diff --git a/lib/tasks/gitlab/packages/migrate.rake b/lib/tasks/gitlab/packages/migrate.rake index cd6dcf78da3..20a8c51db66 100644 --- a/lib/tasks/gitlab/packages/migrate.rake +++ b/lib/tasks/gitlab/packages/migrate.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' desc "GitLab | Packages | Migrate packages files to remote storage" diff --git a/lib/tasks/gitlab/pages.rake b/lib/tasks/gitlab/pages.rake index e15cbb4e32e..b598dab901d 100644 --- a/lib/tasks/gitlab/pages.rake +++ b/lib/tasks/gitlab/pages.rake @@ -1,35 +1,55 @@ +# frozen_string_literal: true + require 'logger' namespace :gitlab do namespace :pages do desc "GitLab | Pages | Migrate legacy storage to zip format" task migrate_legacy_storage: :gitlab_environment do - logger = Logger.new(STDOUT) logger.info('Starting to migrate legacy pages storage to zip deployments') - processed_projects = 0 - - ProjectPagesMetadatum.only_on_legacy_storage.each_batch(of: 10) do |batch| - batch.preload(project: [:namespace, :route, pages_metadatum: :pages_deployment]).each do |metadatum| - project = metadatum.project - - result = nil - time = Benchmark.realtime do - result = ::Pages::MigrateLegacyStorageToDeploymentService.new(project).execute - end - processed_projects += 1 - - if result[:status] == :success - logger.info("project_id: #{project.id} #{project.pages_path} has been migrated in #{time} seconds") - else - logger.error("project_id: #{project.id} #{project.pages_path} failed to be migrated in #{time} seconds: #{result[:message]}") - end - rescue => e - logger.error("#{e.message} project_id: #{project&.id}") - Gitlab::ErrorTracking.track_exception(e, project_id: project&.id) - end - - logger.info("#{processed_projects} pages projects are processed") + + result = ::Pages::MigrateFromLegacyStorageService.new(logger, + migration_threads: migration_threads, + batch_size: batch_size, + ignore_invalid_entries: ignore_invalid_entries).execute + + logger.info("A total of #{result[:migrated] + result[:errored]} projects were processed.") + logger.info("- The #{result[:migrated]} projects migrated successfully") + logger.info("- The #{result[:errored]} projects failed to be migrated") + end + + desc "GitLab | Pages | DANGER: Removes data which was migrated from legacy storage on zip storage. Can be used if some bugs in migration are discovered and migration needs to be restarted from scratch." + task clean_migrated_zip_storage: :gitlab_environment do + destroyed_deployments = 0 + + logger.info("Starting to delete migrated pages deployments") + + ::PagesDeployment.migrated_from_legacy_storage.each_batch(of: batch_size) do |batch| + destroyed_deployments += batch.count + + # we need to destroy associated files, so can't use delete_all + batch.destroy_all # rubocop: disable Cop/DestroyAll + + logger.info("#{destroyed_deployments} deployments were deleted") end end + + def logger + @logger ||= Logger.new(STDOUT) + end + + def migration_threads + ENV.fetch('PAGES_MIGRATION_THREADS', '3').to_i + end + + def batch_size + ENV.fetch('PAGES_MIGRATION_BATCH_SIZE', '10').to_i + end + + def ignore_invalid_entries + Gitlab::Utils.to_boolean( + ENV.fetch('PAGES_MIGRATION_IGNORE_INVALID_ENTRIES', 'false') + ) + end end end diff --git a/lib/tasks/gitlab/password.rake b/lib/tasks/gitlab/password.rake new file mode 100644 index 00000000000..02c28578a2a --- /dev/null +++ b/lib/tasks/gitlab/password.rake @@ -0,0 +1,31 @@ +# frozen_string_literal: true +namespace :gitlab do + namespace :password do + desc "GitLab | Password | Reset a user's password" + task :reset, [:username] => :environment do |_, args| + username = args[:username] || Gitlab::TaskHelpers.prompt('Enter username: ') + abort('Username can not be empty.') if username.blank? + + user = User.find_by(username: username) + abort("Unable to find user with username #{username}.") unless user + + password = Gitlab::TaskHelpers.prompt_for_password + password_confirm = Gitlab::TaskHelpers.prompt_for_password('Confirm password: ') + + user.password = password + user.password_confirmation = password_confirm + user.send_only_admin_changed_your_password_notification! + + unless user.save + message = <<~EOF + Unable to change password of the user with username #{username}. + #{user.errors.full_messages.to_sentence} + EOF + + abort(message) + end + + puts "Password successfully updated for user with username #{username}." + end + end +end diff --git a/lib/tasks/gitlab/praefect.rake b/lib/tasks/gitlab/praefect.rake index a9b126ae379..346df3e0c75 100644 --- a/lib/tasks/gitlab/praefect.rake +++ b/lib/tasks/gitlab/praefect.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :praefect do def int?(string) diff --git a/lib/tasks/gitlab/seed.rake b/lib/tasks/gitlab/seed.rake index d758280ba69..36761165af5 100644 --- a/lib/tasks/gitlab/seed.rake +++ b/lib/tasks/gitlab/seed.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :seed do desc "GitLab | Seed | Seeds issues" diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index 50774de77c9..31bd80e78d4 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do desc "GitLab | Setup production application" task setup: :gitlab_environment do diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index edbaec85bd9..b3abc48f8e0 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :shell do desc "GitLab | Shell | Install or upgrade gitlab-shell" diff --git a/lib/tasks/gitlab/snippets.rake b/lib/tasks/gitlab/snippets.rake index ed2e88692d5..b55f82480e1 100644 --- a/lib/tasks/gitlab/snippets.rake +++ b/lib/tasks/gitlab/snippets.rake @@ -13,7 +13,7 @@ namespace :gitlab do raise "Please supply the list of ids through the SNIPPET_IDS env var" end - raise "Invalid limit value" if limit == 0 + raise "Invalid limit value" if snippet_task_limit == 0 if migration_running? raise "There are already snippet migrations running. Please wait until they are finished." @@ -41,8 +41,8 @@ namespace :gitlab do end end - if ids.size > limit - raise "The number of ids provided is higher than #{limit}. You can update this limit by using the env var `LIMIT`" + if ids.size > snippet_task_limit + raise "The number of ids provided is higher than #{snippet_task_limit}. You can update this limit by using the env var `LIMIT`" end ids @@ -68,14 +68,14 @@ namespace :gitlab do # bundle exec rake gitlab:snippets:list_non_migrated LIMIT=50 desc 'GitLab | Show non migrated snippets' task list_non_migrated: :environment do - raise "Invalid limit value" if limit == 0 + raise "Invalid limit value" if snippet_task_limit == 0 non_migrated_count = non_migrated_snippets.count if non_migrated_count == 0 puts "All snippets have been successfully migrated" else puts "There are #{non_migrated_count} snippets that haven't been migrated. Showing a batch of ids of those snippets:\n" - puts non_migrated_snippets.limit(limit).pluck(:id).join(',') + puts non_migrated_snippets.limit(snippet_task_limit).pluck(:id).join(',') end end @@ -84,7 +84,7 @@ namespace :gitlab do end # There are problems with the specs if we memoize this value - def limit + def snippet_task_limit ENV['LIMIT'] ? ENV['LIMIT'].to_i : DEFAULT_LIMIT end end diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake index f7819fd974b..ede6b6af80b 100644 --- a/lib/tasks/gitlab/storage.rake +++ b/lib/tasks/gitlab/storage.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :storage do desc 'GitLab | Storage | Migrate existing projects to Hashed Storage' diff --git a/lib/tasks/gitlab/tcp_check.rake b/lib/tasks/gitlab/tcp_check.rake index 1400f57d6b9..4790d86832d 100644 --- a/lib/tasks/gitlab/tcp_check.rake +++ b/lib/tasks/gitlab/tcp_check.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do desc "GitLab | Check TCP connectivity to a specific host and port" task :tcp_check, [:host, :port] => :environment do |_t, args| diff --git a/lib/tasks/gitlab/terraform/migrate.rake b/lib/tasks/gitlab/terraform/migrate.rake new file mode 100644 index 00000000000..a9c16049240 --- /dev/null +++ b/lib/tasks/gitlab/terraform/migrate.rake @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'logger' + +desc "GitLab | Terraform | Migrate Terraform states to remote storage" +namespace :gitlab do + namespace :terraform_states do + task migrate: :environment do + logger = Logger.new(STDOUT) + logger.info('Starting transfer of Terraform states to object storage') + + begin + Gitlab::Terraform::StateMigrationHelper.migrate_to_remote_storage do |state_version| + message = "Transferred Terraform state version ID #{state_version.id} (#{state_version.terraform_state.name}/#{state_version.version}) to object storage" + + logger.info(message) + end + rescue => e + logger.error("Failed to migrate: #{e.message}") + end + end + end +end diff --git a/lib/tasks/gitlab/test.rake b/lib/tasks/gitlab/test.rake index 2222807fe13..a83ba69bc75 100644 --- a/lib/tasks/gitlab/test.rake +++ b/lib/tasks/gitlab/test.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do desc "GitLab | Run all tests" task :test do diff --git a/lib/tasks/gitlab/two_factor.rake b/lib/tasks/gitlab/two_factor.rake index 6a9e87e1541..9d10976fbce 100644 --- a/lib/tasks/gitlab/two_factor.rake +++ b/lib/tasks/gitlab/two_factor.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :two_factor do desc "GitLab | 2FA | Disable Two-factor authentication (2FA) for all users" diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake index fdcd34320b1..e3a4e7f50b8 100644 --- a/lib/tasks/gitlab/update_templates.rake +++ b/lib/tasks/gitlab/update_templates.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do desc "GitLab | Update templates" task :update_templates do diff --git a/lib/tasks/gitlab/uploads/check.rake b/lib/tasks/gitlab/uploads/check.rake index 2be2ec7f9c9..8ccc84d15f4 100644 --- a/lib/tasks/gitlab/uploads/check.rake +++ b/lib/tasks/gitlab/uploads/check.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :uploads do desc 'GitLab | Uploads | Check integrity of uploaded files' diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake index 879b07da1df..6052ff90341 100644 --- a/lib/tasks/gitlab/uploads/migrate.rake +++ b/lib/tasks/gitlab/uploads/migrate.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :uploads do namespace :migrate do diff --git a/lib/tasks/gitlab/uploads/sanitize.rake b/lib/tasks/gitlab/uploads/sanitize.rake index 4f23a0a5d82..eec423cbb8b 100644 --- a/lib/tasks/gitlab/uploads/sanitize.rake +++ b/lib/tasks/gitlab/uploads/sanitize.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :uploads do namespace :sanitize do diff --git a/lib/tasks/gitlab/usage_data.rake b/lib/tasks/gitlab/usage_data.rake index d6f5661d5eb..95072444fcf 100644 --- a/lib/tasks/gitlab/usage_data.rake +++ b/lib/tasks/gitlab/usage_data.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :usage_data do desc 'GitLab | UsageData | Generate raw SQLs for usage ping in YAML' @@ -21,5 +23,11 @@ namespace :gitlab do puts Gitlab::Json.pretty_generate(result.attributes) end + + desc 'GitLab | UsageData | Generate metrics dictionary' + task generate_metrics_dictionary: :environment do + items = Gitlab::Usage::MetricDefinition.definitions + Gitlab::Usage::Docs::Renderer.new(items).write + end end end diff --git a/lib/tasks/gitlab/user_management.rake b/lib/tasks/gitlab/user_management.rake index f47e549e795..29f2360f64a 100644 --- a/lib/tasks/gitlab/user_management.rake +++ b/lib/tasks/gitlab/user_management.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :user_management do desc "GitLab | User management | Update all users of a group with personal project limit to 0 and can_create_group to false" diff --git a/lib/tasks/gitlab/web_hook.rake b/lib/tasks/gitlab/web_hook.rake index b242329d720..091743485c9 100644 --- a/lib/tasks/gitlab/web_hook.rake +++ b/lib/tasks/gitlab/web_hook.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :web_hook do desc "GitLab | Webhook | Adds a webhook to the projects" diff --git a/lib/tasks/gitlab/workhorse.rake b/lib/tasks/gitlab/workhorse.rake index 2d72a01f66f..0d9f8efa64f 100644 --- a/lib/tasks/gitlab/workhorse.rake +++ b/lib/tasks/gitlab/workhorse.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :gitlab do namespace :workhorse do desc "GitLab | Workhorse | Install or upgrade gitlab-workhorse" diff --git a/lib/tasks/gitlab/x509/update.rake b/lib/tasks/gitlab/x509/update.rake index eaba9196acf..de878a3d093 100644 --- a/lib/tasks/gitlab/x509/update.rake +++ b/lib/tasks/gitlab/x509/update.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'logger' desc "GitLab | X509 | Update signatures when certificate store has changed" |