in cookbooks/fb_storage/libraries/format_devices_provider.rb [314:378]
def fill_in_dynamic_work(to_do, storage)
needs_work = storage.out_of_spec
format_rules = node['fb_storage']['format'].to_hash
to_do[:fill_arrays] = {}
if format_rules['missing_filesystems_or_partitions']
needs_work[:incomplete_arrays].each do |array, missing|
to_do[:fill_arrays][array] =
missing.reject { |x| device_is_mounted?(x) }
end
end
to_do[:partitions].each do |p|
storage.arrays.each do |array, info|
next if to_do[:arrays].include?(array)
next if info['raid_level'] == 'hybrid_xfs'
if info['members'].include?(p)
to_do[:fill_arrays][array] ||= []
to_do[:fill_arrays][array] << p
end
end
end
to_do[:fill_arrays].each_key do |array|
to_do[:fill_arrays][array].uniq!
end
if converge_all?(format_rules, true) || erase_all?(format_rules, true)
to_do[:stop_arrays] = needs_work[:extra_arrays]
else
to_do[:stop_arrays] = []
partitions_set = Set.new(to_do[:partitions])
needs_work[:extra_arrays].each do |array|
info = node['mdadm'][File.basename(array)]
members_set = Set.new(info['members'].map { |x| "/dev/#{x}" })
if members_set <= partitions_set
Chef::Log.info(
'fb_storage: We will rebuild every device in ' +
"#{array} **and** it's not an array we're configured to want " +
'so we are unmounting and stopping it.',
)
to_do[:stop_arrays] << array
end
end
end
to_do
end