diff options
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/file_hooks.rake | 7 | ||||
-rw-r--r-- | lib/tasks/gitlab/artifacts/migrate.rake | 4 | ||||
-rw-r--r-- | lib/tasks/gitlab/backup.rake | 12 | ||||
-rw-r--r-- | lib/tasks/gitlab/cleanup.rake | 6 | ||||
-rw-r--r-- | lib/tasks/gitlab/db.rake | 27 | ||||
-rw-r--r-- | lib/tasks/gitlab/docs/redirect.rake | 75 | ||||
-rw-r--r-- | lib/tasks/gitlab/doctor/secrets.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/graphql.rake | 7 | ||||
-rw-r--r-- | lib/tasks/gitlab/ldap.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/lfs/migrate.rake | 4 | ||||
-rw-r--r-- | lib/tasks/gitlab/packages/composer.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/packages/events.rake | 4 | ||||
-rw-r--r-- | lib/tasks/gitlab/packages/migrate.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/pages.rake | 6 | ||||
-rw-r--r-- | lib/tasks/gitlab/setup.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/storage.rake | 34 | ||||
-rw-r--r-- | lib/tasks/gitlab/terraform/migrate.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/uploads/migrate.rake | 4 | ||||
-rw-r--r-- | lib/tasks/gitlab/uploads/sanitize.rake | 2 | ||||
-rw-r--r-- | lib/tasks/gitlab/x509/update.rake | 2 | ||||
-rw-r--r-- | lib/tasks/import.rake | 4 | ||||
-rw-r--r-- | lib/tasks/tokens.rake | 2 |
22 files changed, 164 insertions, 48 deletions
diff --git a/lib/tasks/file_hooks.rake b/lib/tasks/file_hooks.rake index a892d36b48e..5eb49808eff 100644 --- a/lib/tasks/file_hooks.rake +++ b/lib/tasks/file_hooks.rake @@ -3,14 +3,9 @@ namespace :file_hooks do desc 'Validate existing file hooks' task validate: :environment do - puts 'Validating file hooks from /file_hooks and /plugins directories' + puts 'Validating file hooks from /file_hooks directories' Gitlab::FileHook.files.each do |file| - if File.dirname(file).ends_with?('plugins') - puts 'DEPRECATED: /plugins directory is deprecated and will be removed in 14.0. ' \ - 'Please move your files into /file_hooks directory.' - end - success, message = Gitlab::FileHook.execute(file, Gitlab::DataBuilder::Push::SAMPLE_DATA) if success diff --git a/lib/tasks/gitlab/artifacts/migrate.rake b/lib/tasks/gitlab/artifacts/migrate.rake index 4c312ea492b..084e7c78906 100644 --- a/lib/tasks/gitlab/artifacts/migrate.rake +++ b/lib/tasks/gitlab/artifacts/migrate.rake @@ -7,7 +7,7 @@ desc 'GitLab | Artifacts | Migrate files for artifacts to comply with new storag namespace :gitlab do namespace :artifacts do task migrate: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) helper = Gitlab::LocalAndRemoteStorageMigration::ArtifactMigrater.new(logger) @@ -19,7 +19,7 @@ namespace :gitlab do end task migrate_to_local: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) helper = Gitlab::LocalAndRemoteStorageMigration::ArtifactMigrater.new(logger) diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index c53ef8382b8..5b17a8c185a 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -109,7 +109,7 @@ namespace :gitlab do puts "GITLAB_BACKUP_MAX_CONCURRENCY and GITLAB_BACKUP_MAX_STORAGE_CONCURRENCY must have a value of at least 1".color(:red) exit 1 else - Backup::Repositories.new(progress).dump( + Backup::Repositories.new(progress, strategy: repository_backup_strategy).dump( max_concurrency: max_concurrency, max_storage_concurrency: max_storage_concurrency ) @@ -119,7 +119,7 @@ namespace :gitlab do task restore: :gitlab_environment do puts_time "Restoring repositories ...".color(:blue) - Backup::Repositories.new(progress).restore + Backup::Repositories.new(progress, strategy: repository_backup_strategy).restore puts_time "done".color(:green) end end @@ -294,6 +294,14 @@ namespace :gitlab do $stdout end end + + def repository_backup_strategy + if Feature.enabled?(:gitaly_backup) + Backup::GitalyBackup.new(progress) + else + Backup::GitalyRpcBackup.new(progress) + end + end end # namespace end: backup end diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake index 6c3a7a77e0e..0cd4ab354c9 100644 --- a/lib/tasks/gitlab/cleanup.rake +++ b/lib/tasks/gitlab/cleanup.rake @@ -92,9 +92,9 @@ namespace :gitlab do task orphan_lfs_files: :gitlab_environment do warn_user_is_not_gitlab - removed_files = RemoveUnreferencedLfsObjectsWorker.new.perform + number_of_removed_files = RemoveUnreferencedLfsObjectsWorker.new.perform - logger.info "Removed unreferenced LFS files: #{removed_files.count}".color(:green) + logger.info "Removed unreferenced LFS files: #{number_of_removed_files}".color(:green) end namespace :sessions do @@ -178,7 +178,7 @@ namespace :gitlab do return @logger if defined?(@logger) @logger = if Rails.env.development? || Rails.env.production? - Logger.new(STDOUT).tap do |stdout_logger| + Logger.new($stdout).tap do |stdout_logger| stdout_logger.extend(ActiveSupport::Logger.broadcast(Rails.logger)) stdout_logger.level = debug? ? Logger::DEBUG : Logger::INFO end diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index bbfdf598e42..ee986f4c503 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -129,16 +129,31 @@ namespace :gitlab do end # Inform Rake that custom tasks should be run every time rake db:structure:dump is run + # + # Rails 6.1 deprecates db:structure:dump in favor of db:schema:dump Rake::Task['db:structure:dump'].enhance do Rake::Task['gitlab:db:clean_structure_sql'].invoke Rake::Task['gitlab:db:dump_custom_structure'].invoke end + # Inform Rake that custom tasks should be run every time rake db:schema:dump is run + Rake::Task['db:schema:dump'].enhance do + Rake::Task['gitlab:db:clean_structure_sql'].invoke + Rake::Task['gitlab:db:dump_custom_structure'].invoke + end + # Inform Rake that custom tasks should be run every time rake db:structure:load is run + # + # Rails 6.1 deprecates db:structure:load in favor of db:schema:load Rake::Task['db:structure:load'].enhance do Rake::Task['gitlab:db:load_custom_structure'].invoke end + # Inform Rake that custom tasks should be run every time rake db:schema:load is run + Rake::Task['db:schema:load'].enhance do + Rake::Task['gitlab:db:load_custom_structure'].invoke + end + desc 'Create missing dynamic database partitions' task :create_dynamic_partitions do Gitlab::Database::Partitioning::PartitionCreator.new.create_partitions @@ -159,10 +174,16 @@ namespace :gitlab do # # Other than that it's helpful to create partitions early when bootstrapping # a new installation. + # + # Rails 6.1 deprecates db:structure:load in favor of db:schema:load Rake::Task['db:structure:load'].enhance do Rake::Task['gitlab:db:create_dynamic_partitions'].invoke end + Rake::Task['db:schema:load'].enhance do + Rake::Task['gitlab:db:create_dynamic_partitions'].invoke + end + # During testing, db:test:load restores the database schema from scratch # which does not include dynamic partitions. We cannot rely on application # initializers here as the application can continue to run while @@ -188,7 +209,7 @@ namespace :gitlab do raise "Index not found or not supported: #{args[:index_name]}" if indexes.empty? end - ActiveRecord::Base.logger = Logger.new(STDOUT) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false) + ActiveRecord::Base.logger = Logger.new($stdout) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false) Gitlab::Database::Reindexing.perform(indexes) rescue StandardError => e @@ -219,9 +240,7 @@ namespace :gitlab do desc 'Run migrations with instrumentation' task migration_testing: :environment do result_dir = Gitlab::Database::Migrations::Instrumentation::RESULT_DIR - raise "Directory exists already, won't overwrite: #{result_dir}" if File.exist?(result_dir) - - Dir.mkdir(result_dir) + FileUtils.mkdir_p(result_dir) verbose_was = ActiveRecord::Migration.verbose ActiveRecord::Migration.verbose = true diff --git a/lib/tasks/gitlab/docs/redirect.rake b/lib/tasks/gitlab/docs/redirect.rake index 0c8e0755348..990ff723eeb 100644 --- a/lib/tasks/gitlab/docs/redirect.rake +++ b/lib/tasks/gitlab/docs/redirect.rake @@ -1,8 +1,11 @@ # frozen_string_literal: true require 'date' require 'pathname' +require "yaml" +# # https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page +# namespace :gitlab do namespace :docs do desc 'GitLab | Docs | Create a doc redirect' @@ -11,14 +14,14 @@ namespace :gitlab do old_path = args.old_path else puts '=> Enter the path of the OLD file:' - old_path = STDIN.gets.chomp + old_path = $stdin.gets.chomp end if args.new_path new_path = args.new_path else puts '=> Enter the path of the NEW file:' - new_path = STDIN.gets.chomp + new_path = $stdin.gets.chomp end # @@ -38,13 +41,14 @@ namespace :gitlab do # - If this is an external URL, move the date 1 year later. # - If this is a relative URL, move the date 3 months later. # - date = Time.now.utc.strftime('%Y-%m-%d') - date = new_path.start_with?('http') ? Date.parse(date) >> 12 : Date.parse(date) >> 3 + today = Time.now.utc.to_date + date = new_path.start_with?('http') ? today >> 12 : today >> 3 puts "=> Creating new redirect from #{old_path} to #{new_path}" File.open(old_path, 'w') do |post| post.puts '---' post.puts "redirect_to: '#{new_path}'" + post.puts "remove_date: '#{date}'" post.puts '---' post.puts post.puts "This file was moved to [another location](#{new_path})." @@ -53,5 +57,68 @@ namespace :gitlab do post.puts "<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page -->" end end + + desc 'GitLab | Docs | Clean up old redirects' + task :clean_redirects do + # + # Calculate new path from the redirect URL. + # + # If the redirect is not a full URL: + # 1. Create a new Pathname of the file + # 2. Use dirname to get all but the last component of the path + # 3. Join with the redirect_to entry + # 4. Substitute: + # - '.md' => '.html' + # - 'doc/' => '/ee/' + # + # If the redirect URL is a full URL pointing to the Docs site + # (cross-linking among the 4 products), remove the FQDN prefix: + # + # From : https://docs.gitlab.com/ee/install/requirements.html + # To : /ee/install/requirements.html + # + def new_path(redirect, filename) + if !redirect.start_with?('http') + Pathname.new(filename).dirname.join(redirect).to_s.gsub(%r(\.md), '.html').gsub(%r(doc/), '/ee/') + elsif redirect.start_with?('https://docs.gitlab.com') + redirect.gsub('https://docs.gitlab.com', '') + else + redirect + end + end + + today = Time.now.utc.to_date + + # + # Find the files to be deleted. + # Exclude 'doc/development/documentation/index.md' because it + # contains an example of the YAML front matter. + # + files_to_be_deleted = `grep -Ir 'remove_date:' doc | grep -v doc/development/documentation/index.md | cut -d ":" -f 1`.split("\n") + + # + # Iterate over the files to be deleted and print the needed + # YAML entries for the Docs site redirects. + # + files_to_be_deleted.each do |filename| + frontmatter = YAML.safe_load(File.read(filename)) + remove_date = Date.parse(frontmatter['remove_date']) + old_path = filename.gsub(%r(\.md), '.html').gsub(%r(doc/), '/ee/') + + # + # Check if the removal date is before today, and delete the file and + # print the content to be pasted in + # https://gitlab.com/gitlab-org/gitlab-docs/-/blob/master/content/_data/redirects.yaml. + # The remove_date of redirects.yaml should be nine months in the future. + # To not be confused with the remove_date of the Markdown page. + # + next unless remove_date < today + + File.delete(filename) if File.exist?(filename) + puts " - from: #{old_path}" + puts " to: #{new_path(frontmatter['redirect_to'], filename)}" + puts " remove_date: #{remove_date >> 9}" + end + end end end diff --git a/lib/tasks/gitlab/doctor/secrets.rake b/lib/tasks/gitlab/doctor/secrets.rake index 6e3f474312c..29f0f36c705 100644 --- a/lib/tasks/gitlab/doctor/secrets.rake +++ b/lib/tasks/gitlab/doctor/secrets.rake @@ -4,7 +4,7 @@ namespace :gitlab do namespace :doctor do desc "GitLab | Check if the database encrypted values can be decrypted using current secrets" task secrets: :gitlab_environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.level = Gitlab::Utils.to_boolean(ENV['VERBOSE']) ? Logger::DEBUG : Logger::INFO diff --git a/lib/tasks/gitlab/graphql.rake b/lib/tasks/gitlab/graphql.rake index 27bba6aa307..b405cbd3f68 100644 --- a/lib/tasks/gitlab/graphql.rake +++ b/lib/tasks/gitlab/graphql.rake @@ -3,11 +3,12 @@ return if Rails.env.production? require 'graphql/rake_task' +require_relative '../../../tooling/graphql/docs/renderer' namespace :gitlab do OUTPUT_DIR = Rails.root.join("doc/api/graphql/reference") TEMP_SCHEMA_DIR = Rails.root.join('tmp/tests/graphql') - TEMPLATES_DIR = 'lib/gitlab/graphql/docs/templates/' + TEMPLATES_DIR = 'tooling/graphql/docs/templates/' # Make all feature flags enabled so that all feature flag # controlled fields are considered visible and are output. @@ -110,7 +111,7 @@ namespace :gitlab do desc 'GitLab | GraphQL | Generate GraphQL docs' task compile_docs: [:environment, :enable_feature_flags] do - renderer = Gitlab::Graphql::Docs::Renderer.new(GitlabSchema, render_options) + renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options) renderer.write @@ -119,7 +120,7 @@ namespace :gitlab do desc 'GitLab | GraphQL | Check if GraphQL docs are up to date' task check_docs: [:environment, :enable_feature_flags] do - renderer = Gitlab::Graphql::Docs::Renderer.new(GitlabSchema, render_options) + renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options) doc = File.read(Rails.root.join(OUTPUT_DIR, 'index.md')) diff --git a/lib/tasks/gitlab/ldap.rake b/lib/tasks/gitlab/ldap.rake index 3b2834c0008..4da22e686ef 100644 --- a/lib/tasks/gitlab/ldap.rake +++ b/lib/tasks/gitlab/ldap.rake @@ -42,7 +42,7 @@ namespace :gitlab do namespace :secret do desc 'GitLab | LDAP | Secret | Write LDAP secrets' task write: [:environment] do - content = STDIN.tty? ? STDIN.gets : STDIN.read + content = $stdin.tty? ? $stdin.gets : $stdin.read Gitlab::EncryptedLdapCommand.write(content) end diff --git a/lib/tasks/gitlab/lfs/migrate.rake b/lib/tasks/gitlab/lfs/migrate.rake index a173de7c5c7..47f9e1dfb32 100644 --- a/lib/tasks/gitlab/lfs/migrate.rake +++ b/lib/tasks/gitlab/lfs/migrate.rake @@ -6,7 +6,7 @@ desc "GitLab | LFS | Migrate LFS objects to remote storage" namespace :gitlab do namespace :lfs do task migrate: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.info('Starting transfer of LFS files to object storage') LfsObject.with_files_stored_locally @@ -20,7 +20,7 @@ namespace :gitlab do end task migrate_to_local: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.info('Starting transfer of LFS files to local storage') LfsObject.with_files_stored_remotely diff --git a/lib/tasks/gitlab/packages/composer.rake b/lib/tasks/gitlab/packages/composer.rake index c9bccfe9384..97f1da0ff63 100644 --- a/lib/tasks/gitlab/packages/composer.rake +++ b/lib/tasks/gitlab/packages/composer.rake @@ -6,7 +6,7 @@ desc "GitLab | Packages | Build composer cache" namespace :gitlab do namespace :packages do task build_composer_cache: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.info('Starting to build composer cache files') ::Packages::Package.composer.find_in_batches do |packages| diff --git a/lib/tasks/gitlab/packages/events.rake b/lib/tasks/gitlab/packages/events.rake index d24535d85b6..a5b801ff62d 100644 --- a/lib/tasks/gitlab/packages/events.rake +++ b/lib/tasks/gitlab/packages/events.rake @@ -14,7 +14,7 @@ namespace :gitlab do end task generate_counts: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.info('Building list of package events...') path = Gitlab::UsageDataCounters::PackageEventCounter::KNOWN_EVENTS_PATH @@ -26,7 +26,7 @@ namespace :gitlab do end task generate_unique: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.info('Building list of package events...') path = File.join(File.dirname(Gitlab::UsageDataCounters::HLLRedisCounter::KNOWN_EVENTS_PATH), 'package_events.yml') diff --git a/lib/tasks/gitlab/packages/migrate.rake b/lib/tasks/gitlab/packages/migrate.rake index febc3e7fa2d..1c28f4308a2 100644 --- a/lib/tasks/gitlab/packages/migrate.rake +++ b/lib/tasks/gitlab/packages/migrate.rake @@ -6,7 +6,7 @@ desc "GitLab | Packages | Migrate packages files to remote storage" namespace :gitlab do namespace :packages do task migrate: :environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) logger.info('Starting transfer of package files to object storage') unless ::Packages::PackageFileUploader.object_store_enabled? diff --git a/lib/tasks/gitlab/pages.rake b/lib/tasks/gitlab/pages.rake index 684d62d1367..c3828e7eba4 100644 --- a/lib/tasks/gitlab/pages.rake +++ b/lib/tasks/gitlab/pages.rake @@ -35,7 +35,7 @@ namespace :gitlab do end def logger - @logger ||= Logger.new(STDOUT) + @logger ||= Logger.new($stdout) end def migration_threads @@ -60,7 +60,7 @@ namespace :gitlab do namespace :deployments do task migrate_to_object_storage: :gitlab_environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) helper = Gitlab::LocalAndRemoteStorageMigration::PagesDeploymentMigrater.new(logger) @@ -72,7 +72,7 @@ namespace :gitlab do end task migrate_to_local: :gitlab_environment do - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) helper = Gitlab::LocalAndRemoteStorageMigration::PagesDeploymentMigrater.new(logger) diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index 31bd80e78d4..705519d1741 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -40,7 +40,7 @@ namespace :gitlab do end # If there are any clients connected to the DB, PostgreSQL won't let - # you drop the database. It's possible that Sidekiq, Unicorn, or + # you drop the database. It's possible that Sidekiq, Puma, or # some other client will be hanging onto a connection, preventing # the DROP DATABASE from working. To workaround this problem, this # method terminates all the connections so that a subsequent DROP diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake index ede6b6af80b..6fa39a26488 100644 --- a/lib/tasks/gitlab/storage.rake +++ b/lib/tasks/gitlab/storage.rake @@ -96,8 +96,12 @@ namespace :gitlab do desc 'Gitlab | Storage | Summary of existing projects using Legacy Storage' task legacy_projects: :environment do - helper = Gitlab::HashedStorage::RakeHelper - helper.relation_summary('projects using Legacy Storage', Project.without_storage_feature(:repository)) + # Required to prevent Docker upgrade to 14.0 if there data on legacy storage + # See: https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/5311#note_590454698 + wait_until_database_is_ready do + helper = Gitlab::HashedStorage::RakeHelper + helper.relation_summary('projects using Legacy Storage', Project.without_storage_feature(:repository)) + end end desc 'Gitlab | Storage | List existing projects using Legacy Storage' @@ -135,8 +139,12 @@ namespace :gitlab do desc 'Gitlab | Storage | Summary of project attachments using Legacy Storage' task legacy_attachments: :environment do - helper = Gitlab::HashedStorage::RakeHelper - helper.relation_summary('attachments using Legacy Storage', helper.legacy_attachments_relation) + # Required to prevent Docker upgrade to 14.0 if there data on legacy storage + # See: https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/5311#note_590454698 + wait_until_database_is_ready do + helper = Gitlab::HashedStorage::RakeHelper + helper.relation_summary('attachments using Legacy Storage', helper.legacy_attachments_relation) + end end desc 'Gitlab | Storage | List existing project attachments using Legacy Storage' @@ -156,5 +164,23 @@ namespace :gitlab do helper = Gitlab::HashedStorage::RakeHelper helper.attachments_list('attachments using Hashed Storage', helper.hashed_attachments_relation) end + + def wait_until_database_is_ready + attempts = (ENV['MAX_DATABASE_CONNECTION_CHECKS'] || 1).to_i + inverval = (ENV['MAX_DATABASE_CONNECTION_CHECK_INTERVAL'] || 10).to_f + + attempts.to_i.times do + unless Gitlab::Database.exists? + puts "Waiting until database is ready before continuing...".color(:yellow) + sleep inverval + end + end + + yield + rescue ActiveRecord::ConnectionNotEstablished => ex + puts "Failed to connect to the database...".color(:red) + puts "Error: #{ex}" + exit 1 + end end end diff --git a/lib/tasks/gitlab/terraform/migrate.rake b/lib/tasks/gitlab/terraform/migrate.rake index 2bf9ec9537a..99e33011cf5 100644 --- a/lib/tasks/gitlab/terraform/migrate.rake +++ b/lib/tasks/gitlab/terraform/migrate.rake @@ -6,7 +6,7 @@ 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 = Logger.new($stdout) logger.info('Starting transfer of Terraform states to object storage') begin diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake index 6052ff90341..80290f95e8e 100644 --- a/lib/tasks/gitlab/uploads/migrate.rake +++ b/lib/tasks/gitlab/uploads/migrate.rake @@ -16,7 +16,7 @@ namespace :gitlab do # category to object storage desc 'GitLab | Uploads | Migrate the uploaded files of specified type to object storage' task :migrate, [:uploader_class, :model_class, :mounted_as] => :environment do |_t, args| - Gitlab::Uploads::MigrationHelper.new(args, Logger.new(STDOUT)).migrate_to_remote_storage + Gitlab::Uploads::MigrationHelper.new(args, Logger.new($stdout)).migrate_to_remote_storage end namespace :migrate_to_local do @@ -31,7 +31,7 @@ namespace :gitlab do desc 'GitLab | Uploads | Migrate the uploaded files of specified type to local storage' task :migrate_to_local, [:uploader_class, :model_class, :mounted_as] => :environment do |_t, args| - Gitlab::Uploads::MigrationHelper.new(args, Logger.new(STDOUT)).migrate_to_local_storage + Gitlab::Uploads::MigrationHelper.new(args, Logger.new($stdout)).migrate_to_local_storage end end end diff --git a/lib/tasks/gitlab/uploads/sanitize.rake b/lib/tasks/gitlab/uploads/sanitize.rake index eec423cbb8b..40f6a7bb67d 100644 --- a/lib/tasks/gitlab/uploads/sanitize.rake +++ b/lib/tasks/gitlab/uploads/sanitize.rake @@ -8,7 +8,7 @@ namespace :gitlab do args.with_defaults(dry_run: 'true') args.with_defaults(sleep_time: 0.3) - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) sanitizer = Gitlab::Sanitizers::Exif.new(logger: logger) sanitizer.batch_clean(start_id: args.start_id, stop_id: args.stop_id, diff --git a/lib/tasks/gitlab/x509/update.rake b/lib/tasks/gitlab/x509/update.rake index de878a3d093..d3c63fa8514 100644 --- a/lib/tasks/gitlab/x509/update.rake +++ b/lib/tasks/gitlab/x509/update.rake @@ -10,7 +10,7 @@ namespace :gitlab do end def update_certificates - logger = Logger.new(STDOUT) + logger = Logger.new($stdout) unless X509CommitSignature.exists? logger.info("Unable to find any x509 commit signatures. Exiting.") diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 633beb132d8..b7a5cbe44b9 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -38,7 +38,7 @@ class GithubImport puts "This will import GitHub #{@repo.full_name.bright} into GitLab #{@project_path.bright} as #{@current_user.name}" puts "Permission checks are ignored. Press any key to continue.".color(:red) - STDIN.getch + $stdin.getch puts 'Starting the import (this could take a while)'.color(:green) end @@ -131,7 +131,7 @@ class GithubRepos end def repo_id - @repo_id ||= STDIN.gets.chomp.to_i + @repo_id ||= $stdin.gets.chomp.to_i end def repos diff --git a/lib/tasks/tokens.rake b/lib/tasks/tokens.rake index 74baa11c314..ff14ab51b49 100644 --- a/lib/tasks/tokens.rake +++ b/lib/tasks/tokens.rake @@ -19,7 +19,7 @@ namespace :tokens do def reset_all_users_token(reset_token_method) TmpUser.find_in_batches do |batch| puts "Processing batch starting with user ID: #{batch.first.id}" - STDOUT.flush + $stdout.flush batch.each(&reset_token_method) end |