Loading lib/tasks/gitlab/task_helpers.rb→lib/gitlab/task_helpers.rb +0 −0 File moved. View file lib/system_check/helpers.rb +0 −2 Original line number Diff line number Diff line require 'tasks/gitlab/task_helpers' module SystemCheck module Helpers include ::Gitlab::TaskHelpers Loading lib/tasks/gitlab/backup.rake +18 −18 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ namespace :gitlab do namespace :backup do # Create backup of GitLab system desc "GitLab | Create a backup of the GitLab system" task create: :environment do task create: :gitlab_environment do warn_user_is_not_gitlab configure_cron_mode Loading @@ -25,7 +25,7 @@ namespace :gitlab do # Restore backup of GitLab system desc 'GitLab | Restore a previously created backup' task restore: :environment do task restore: :gitlab_environment do warn_user_is_not_gitlab configure_cron_mode Loading Loading @@ -73,7 +73,7 @@ namespace :gitlab do end namespace :repo do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping repositories ...".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("repositories") Loading @@ -84,7 +84,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring repositories ...".color(:blue) Backup::Repository.new.restore $progress.puts "done".color(:green) Loading @@ -92,7 +92,7 @@ namespace :gitlab do end namespace :db do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping database ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("db") Loading @@ -103,7 +103,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring database ... ".color(:blue) Backup::Database.new.restore $progress.puts "done".color(:green) Loading @@ -111,7 +111,7 @@ namespace :gitlab do end namespace :builds do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping builds ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("builds") Loading @@ -122,7 +122,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring builds ... ".color(:blue) Backup::Builds.new.restore $progress.puts "done".color(:green) Loading @@ -130,7 +130,7 @@ namespace :gitlab do end namespace :uploads do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping uploads ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("uploads") Loading @@ -141,7 +141,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring uploads ... ".color(:blue) Backup::Uploads.new.restore $progress.puts "done".color(:green) Loading @@ -149,7 +149,7 @@ namespace :gitlab do end namespace :artifacts do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping artifacts ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("artifacts") Loading @@ -160,7 +160,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring artifacts ... ".color(:blue) Backup::Artifacts.new.restore $progress.puts "done".color(:green) Loading @@ -168,7 +168,7 @@ namespace :gitlab do end namespace :pages do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping pages ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("pages") Loading @@ -179,7 +179,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring pages ... ".color(:blue) Backup::Pages.new.restore $progress.puts "done".color(:green) Loading @@ -187,7 +187,7 @@ namespace :gitlab do end namespace :lfs do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping lfs objects ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("lfs") Loading @@ -198,7 +198,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring lfs objects ... ".color(:blue) Backup::Lfs.new.restore $progress.puts "done".color(:green) Loading @@ -206,7 +206,7 @@ namespace :gitlab do end namespace :registry do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping container registry images ... ".color(:blue) if Gitlab.config.registry.enabled Loading @@ -221,7 +221,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring container registry images ... ".color(:blue) if Gitlab.config.registry.enabled Loading lib/tasks/gitlab/check.rake +10 −14 Original line number Diff line number Diff line # Temporary hack, until we migrate all checks to SystemCheck format require 'system_check' require 'system_check/helpers' namespace :gitlab do desc 'GitLab | Check the configuration of GitLab and its environment' task check: %w{gitlab:gitlab_shell:check Loading @@ -12,7 +8,7 @@ namespace :gitlab do namespace :app do desc 'GitLab | Check the configuration of the GitLab Rails app' task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab checks = [ Loading Loading @@ -43,7 +39,7 @@ namespace :gitlab do namespace :gitlab_shell do desc "GitLab | Check the configuration of GitLab Shell" task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab start_checking "GitLab Shell" Loading Loading @@ -251,7 +247,7 @@ namespace :gitlab do namespace :sidekiq do desc "GitLab | Check the configuration of Sidekiq" task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab start_checking "Sidekiq" Loading Loading @@ -310,7 +306,7 @@ namespace :gitlab do namespace :incoming_email do desc "GitLab | Check the configuration of Reply by email" task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab if Gitlab.config.incoming_email.enabled Loading @@ -333,7 +329,7 @@ namespace :gitlab do end namespace :ldap do task :check, [:limit] => :environment do |_, args| task :check, [:limit] => :gitlab_environment do |_, args| # Only show up to 100 results because LDAP directories can be very big. # This setting only affects the `rake gitlab:check` script. args.with_defaults(limit: 100) Loading Loading @@ -389,7 +385,7 @@ namespace :gitlab do namespace :repo do desc "GitLab | Check the integrity of the repositories managed by GitLab" task check: :environment do task check: :gitlab_environment do puts "This task is deprecated. Please use gitlab:git:fsck instead".color(:red) Rake::Task["gitlab:git:fsck"].execute end Loading @@ -397,7 +393,7 @@ namespace :gitlab do namespace :orphans do desc 'Gitlab | Check for orphaned namespaces and repositories' task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab checks = [ SystemCheck::Orphans::NamespaceCheck, Loading @@ -408,7 +404,7 @@ namespace :gitlab do end desc 'GitLab | Check for orphaned namespaces in the repositories path' task check_namespaces: :environment do task check_namespaces: :gitlab_environment do warn_user_is_not_gitlab checks = [SystemCheck::Orphans::NamespaceCheck] Loading @@ -416,7 +412,7 @@ namespace :gitlab do end desc 'GitLab | Check for orphaned repositories in the repositories path' task check_repositories: :environment do task check_repositories: :gitlab_environment do warn_user_is_not_gitlab checks = [SystemCheck::Orphans::RepositoryCheck] Loading @@ -426,7 +422,7 @@ namespace :gitlab do namespace :user do desc "GitLab | Check the integrity of a specific user's repositories" task :check_repos, [:username] => :environment do |t, args| task :check_repos, [:username] => :gitlab_environment do |t, args| username = args[:username] || prompt("Check repository integrity for username? ".color(:blue)) user = User.find_by(username: username) if user Loading lib/tasks/gitlab/cleanup.rake +4 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ namespace :gitlab do HASHED_REPOSITORY_NAME = '@hashed'.freeze desc "GitLab | Cleanup | Clean namespaces" task dirs: :environment do task dirs: :gitlab_environment do warn_user_is_not_gitlab remove_flag = ENV['REMOVE'] Loading Loading @@ -49,7 +49,7 @@ namespace :gitlab do end desc "GitLab | Cleanup | Clean repositories" task repos: :environment do task repos: :gitlab_environment do warn_user_is_not_gitlab move_suffix = "+orphaned+#{Time.now.to_i}" Loading Loading @@ -78,7 +78,7 @@ namespace :gitlab do end desc "GitLab | Cleanup | Block users that have been removed in LDAP" task block_removed_ldap_users: :environment do task block_removed_ldap_users: :gitlab_environment do warn_user_is_not_gitlab block_flag = ENV['BLOCK'] Loading Loading @@ -109,7 +109,7 @@ namespace :gitlab do # released. So likely this should only be run once on gitlab.com # Faulty refs are moved so they are kept around, else some features break. desc 'GitLab | Cleanup | Remove faulty deployment refs' task move_faulty_deployment_refs: :environment do task move_faulty_deployment_refs: :gitlab_environment do projects = Project.where(id: Deployment.select(:project_id).distinct) projects.find_each do |project| Loading Loading
lib/system_check/helpers.rb +0 −2 Original line number Diff line number Diff line require 'tasks/gitlab/task_helpers' module SystemCheck module Helpers include ::Gitlab::TaskHelpers Loading
lib/tasks/gitlab/backup.rake +18 −18 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ namespace :gitlab do namespace :backup do # Create backup of GitLab system desc "GitLab | Create a backup of the GitLab system" task create: :environment do task create: :gitlab_environment do warn_user_is_not_gitlab configure_cron_mode Loading @@ -25,7 +25,7 @@ namespace :gitlab do # Restore backup of GitLab system desc 'GitLab | Restore a previously created backup' task restore: :environment do task restore: :gitlab_environment do warn_user_is_not_gitlab configure_cron_mode Loading Loading @@ -73,7 +73,7 @@ namespace :gitlab do end namespace :repo do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping repositories ...".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("repositories") Loading @@ -84,7 +84,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring repositories ...".color(:blue) Backup::Repository.new.restore $progress.puts "done".color(:green) Loading @@ -92,7 +92,7 @@ namespace :gitlab do end namespace :db do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping database ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("db") Loading @@ -103,7 +103,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring database ... ".color(:blue) Backup::Database.new.restore $progress.puts "done".color(:green) Loading @@ -111,7 +111,7 @@ namespace :gitlab do end namespace :builds do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping builds ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("builds") Loading @@ -122,7 +122,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring builds ... ".color(:blue) Backup::Builds.new.restore $progress.puts "done".color(:green) Loading @@ -130,7 +130,7 @@ namespace :gitlab do end namespace :uploads do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping uploads ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("uploads") Loading @@ -141,7 +141,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring uploads ... ".color(:blue) Backup::Uploads.new.restore $progress.puts "done".color(:green) Loading @@ -149,7 +149,7 @@ namespace :gitlab do end namespace :artifacts do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping artifacts ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("artifacts") Loading @@ -160,7 +160,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring artifacts ... ".color(:blue) Backup::Artifacts.new.restore $progress.puts "done".color(:green) Loading @@ -168,7 +168,7 @@ namespace :gitlab do end namespace :pages do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping pages ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("pages") Loading @@ -179,7 +179,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring pages ... ".color(:blue) Backup::Pages.new.restore $progress.puts "done".color(:green) Loading @@ -187,7 +187,7 @@ namespace :gitlab do end namespace :lfs do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping lfs objects ... ".color(:blue) if ENV["SKIP"] && ENV["SKIP"].include?("lfs") Loading @@ -198,7 +198,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring lfs objects ... ".color(:blue) Backup::Lfs.new.restore $progress.puts "done".color(:green) Loading @@ -206,7 +206,7 @@ namespace :gitlab do end namespace :registry do task create: :environment do task create: :gitlab_environment do $progress.puts "Dumping container registry images ... ".color(:blue) if Gitlab.config.registry.enabled Loading @@ -221,7 +221,7 @@ namespace :gitlab do end end task restore: :environment do task restore: :gitlab_environment do $progress.puts "Restoring container registry images ... ".color(:blue) if Gitlab.config.registry.enabled Loading
lib/tasks/gitlab/check.rake +10 −14 Original line number Diff line number Diff line # Temporary hack, until we migrate all checks to SystemCheck format require 'system_check' require 'system_check/helpers' namespace :gitlab do desc 'GitLab | Check the configuration of GitLab and its environment' task check: %w{gitlab:gitlab_shell:check Loading @@ -12,7 +8,7 @@ namespace :gitlab do namespace :app do desc 'GitLab | Check the configuration of the GitLab Rails app' task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab checks = [ Loading Loading @@ -43,7 +39,7 @@ namespace :gitlab do namespace :gitlab_shell do desc "GitLab | Check the configuration of GitLab Shell" task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab start_checking "GitLab Shell" Loading Loading @@ -251,7 +247,7 @@ namespace :gitlab do namespace :sidekiq do desc "GitLab | Check the configuration of Sidekiq" task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab start_checking "Sidekiq" Loading Loading @@ -310,7 +306,7 @@ namespace :gitlab do namespace :incoming_email do desc "GitLab | Check the configuration of Reply by email" task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab if Gitlab.config.incoming_email.enabled Loading @@ -333,7 +329,7 @@ namespace :gitlab do end namespace :ldap do task :check, [:limit] => :environment do |_, args| task :check, [:limit] => :gitlab_environment do |_, args| # Only show up to 100 results because LDAP directories can be very big. # This setting only affects the `rake gitlab:check` script. args.with_defaults(limit: 100) Loading Loading @@ -389,7 +385,7 @@ namespace :gitlab do namespace :repo do desc "GitLab | Check the integrity of the repositories managed by GitLab" task check: :environment do task check: :gitlab_environment do puts "This task is deprecated. Please use gitlab:git:fsck instead".color(:red) Rake::Task["gitlab:git:fsck"].execute end Loading @@ -397,7 +393,7 @@ namespace :gitlab do namespace :orphans do desc 'Gitlab | Check for orphaned namespaces and repositories' task check: :environment do task check: :gitlab_environment do warn_user_is_not_gitlab checks = [ SystemCheck::Orphans::NamespaceCheck, Loading @@ -408,7 +404,7 @@ namespace :gitlab do end desc 'GitLab | Check for orphaned namespaces in the repositories path' task check_namespaces: :environment do task check_namespaces: :gitlab_environment do warn_user_is_not_gitlab checks = [SystemCheck::Orphans::NamespaceCheck] Loading @@ -416,7 +412,7 @@ namespace :gitlab do end desc 'GitLab | Check for orphaned repositories in the repositories path' task check_repositories: :environment do task check_repositories: :gitlab_environment do warn_user_is_not_gitlab checks = [SystemCheck::Orphans::RepositoryCheck] Loading @@ -426,7 +422,7 @@ namespace :gitlab do namespace :user do desc "GitLab | Check the integrity of a specific user's repositories" task :check_repos, [:username] => :environment do |t, args| task :check_repos, [:username] => :gitlab_environment do |t, args| username = args[:username] || prompt("Check repository integrity for username? ".color(:blue)) user = User.find_by(username: username) if user Loading
lib/tasks/gitlab/cleanup.rake +4 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ namespace :gitlab do HASHED_REPOSITORY_NAME = '@hashed'.freeze desc "GitLab | Cleanup | Clean namespaces" task dirs: :environment do task dirs: :gitlab_environment do warn_user_is_not_gitlab remove_flag = ENV['REMOVE'] Loading Loading @@ -49,7 +49,7 @@ namespace :gitlab do end desc "GitLab | Cleanup | Clean repositories" task repos: :environment do task repos: :gitlab_environment do warn_user_is_not_gitlab move_suffix = "+orphaned+#{Time.now.to_i}" Loading Loading @@ -78,7 +78,7 @@ namespace :gitlab do end desc "GitLab | Cleanup | Block users that have been removed in LDAP" task block_removed_ldap_users: :environment do task block_removed_ldap_users: :gitlab_environment do warn_user_is_not_gitlab block_flag = ENV['BLOCK'] Loading Loading @@ -109,7 +109,7 @@ namespace :gitlab do # released. So likely this should only be run once on gitlab.com # Faulty refs are moved so they are kept around, else some features break. desc 'GitLab | Cleanup | Remove faulty deployment refs' task move_faulty_deployment_refs: :environment do task move_faulty_deployment_refs: :gitlab_environment do projects = Project.where(id: Deployment.select(:project_id).distinct) projects.find_each do |project| Loading