blob: 1963cbfc985a2bf91b67ca42d01d6cd7c39f5bf8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module SystemCheck
module Orphans
class NamespaceCheck < SystemCheck::BaseCheck
set_name 'Orphaned namespaces:'
def multi_check
Gitlab.config.repositories.storages.each do |name, repository_storage|
$stdout.puts
$stdout.puts "* Storage: #{name} (#{repository_storage['path']})".color(:yellow)
toplevel_namespace_dirs = Dir.glob(File.join(repository_storage['path'], '*')).map{|p| File.basename(p)}
orphans = (toplevel_namespace_dirs - existing_namespaces)
if orphans.empty?
$stdout.puts "* No orphaned namespaces for #{name} storage".color(:green)
next
end
orphans.each do |orphan|
$stdout.puts " - #{orphan}".color(:red)
end
end
clear_namespaces! # releases memory when check finishes
end
private
def existing_namespaces
@namespaces ||= Namespace.all.pluck(:path)
end
def clear_namespaces!
@namespaces = nil
end
end
end
end
|