in cookbooks/fb_storage/libraries/storage_handlers.rb [318:403]
def remove_device_from_any_arrays(device)
array = array_device_is_in(device)
unless array
Chef::Log.debug(
"fb_storage: #{device} not found in any arrays",
)
return
end
unless File.exist?(array)
Chef::Log.debug(
"fb_storage: Skipping removing #{device} from " +
"#{array} because #{array} no longer exists",
)
return
end
Chef::Log.info(
"fb_storage: Removing #{device} from #{array}",
)
s = Mixlib::ShellOut.new(
"#{MDADM} #{array} --fail #{device}",
).run_command
if s.stderr.include?('Device or resource busy') &&
@node['fb_storage']['stop_and_zero_mdadm_for_format']
Chef::Log.info("fb_storage: Stopping array #{array}...")
stop_array(array)
Chef::Log.info(
"fb_storage: Zeroing superblock for #{device}...",
)
nuke_raid_header(device)
return
else
s.error!
end
_sleep(2)
tries = 0
max_tries = 6
interval = 10
loop do
s = Mixlib::ShellOut.new(
"#{MDADM} #{array} --remove #{device}",
).run_command
break unless s.error?
unless s.stdout.include?('Device or resource busy')
s.error!
end
if tries == max_tries
Chef::Log.error(
"fb_storage: Failed to remove #{device} from " +
"#{array} after #{max_tries} tries",
)
s.error!
end
Chef::Log.info(
"fb_storage: #{device} still busy after setting it " +
"faulty - sleeping #{interval} seconds and trying again to " +
'remove it.',
)
_sleep(interval)
tries += 1
end
end