Adjust wait to allow erase_node to send response

This change changes the way the erase_node action performs the cleanup
of the disks. We attempt to remount any ext2/3/4 devices as RO and
set the error action to continue. Additionally we are no longer using
sysrq to sync all file systems, reboot all file systems, or sending a
SIGTERM to all processes. Now the disk erase occurs and a sysrq to
reboot the machine after 5 seconds via a forked process. This should
allow for mcollective to send back the response to the fuel node to
acknowledge the erase_node action.

Change-Id: If5ce3d1c2ce99ec422a372bfc30b273583f9fb38
Closes-Bug: 1461074
This commit is contained in:
Alex Schultz 2015-06-09 13:03:53 -05:00
parent 7766818f07
commit a6218d4696
1 changed files with 23 additions and 20 deletions

View File

@ -100,24 +100,24 @@ module MCollective
end
def reboot
debug_msg("Run node rebooting command using 'SB' to sysrq-trigger")
debug_msg("Beginning drive erase process")
File.open('/proc/sys/kernel/sysrq','w') { |file| file.write("1\n") }
# turning panic on oops and setting panic timeout to 10
File.open('/proc/sys/kernel/panic_on_oops', 'w') {|file| file.write("1\n")}
File.open('/proc/sys/kernel/panic','w') {|file| file.write("10\n")}
#Setting RO for all file systems
['s', 'u'].each do |req|
File.open('/proc/sysrq-trigger','w') do |file|
file.write("#{req}\n")
end
end
begin
# Delete data disks first, then OS drive to address bug #1437511
(get_devices(type='data') + get_devices(type='root')).each do |dev|
debug_msg("erasing #{dev[:name]}")
# try an make sure any ext2/3/4 paritions won't cause a panic
# when the file system gets erased
suppress_fs_panic(dev[:name])
# clear out the partitions of the device
erase_partitions(dev[:name])
# attempt to clear our the file system data on the device partitions
# to ensure that we aren't left with extra filesystem data when we
# reparition the devices next time.
erase_data(dev[:name])
erase_data(dev[:name], 1, dev[:size], '512')
end
@ -131,26 +131,29 @@ module MCollective
error_msg << msg
end
debug_msg("Drives erased, rebooting in 5 seconds.")
# It should be noted that this is here so that astute will get a reply
# from the deletion task. If it does not get a reply, the deletion may
# fail. LP#1279720
pid = fork do
trap('SIGTERM') do
sleep 5
# Reboot the system
['b'].each do |req|
File.open('/proc/sysrq-trigger','w') do |file|
file.write("#{req}\n")
end
end
end
# Sending SIGTERM to all processes
File.open('/proc/sysrq-trigger','w') { |file| file.write("e\n")}
# sleep to let parent send response back to server
sleep 5
# Reboot the system
File.open('/proc/sysrq-trigger','w') { |file| file.write("b\n")}
end
Process.detach(pid)
end
def suppress_fs_panic(dev)
Dir["/dev/#{dev}{p,}[0-9]*"].each do |part|
# if the partition has ext2/3/4, make sure error action is set to
# continue and not panic so that we can erase it correctly.
if system("blkid -p -n ext2,ext3,ext4 #{part}") == true && system("findmnt -ln -S #{part}") == true
system("mount -o remount,ro,errors=continue #{part}")
end
end
end
def erase_partitions(dev)
Dir["/dev/#{dev}{p,}[0-9]*"].each do |part|
system("dd if=/dev/zero of=#{part} bs=1M count=10 oflag=direct")