Correct node erase sequence
This sequence is more accurate as it sends SIGTERM to all processes. - Send SIGTERM to all processes - Trap SIGTERM - Sync and set RO flag on all partitions - Erase bootable partitions with dd - Send "b" to sysrq-trigger Closes-Bug: 1268641 Closes-Bug: 1279720 Change-Id: I4eaa6ed9b2872f55efaff0a874ac280bdba02226
This commit is contained in:
parent
17b1afa5f0
commit
694b5a5569
@ -46,24 +46,6 @@ module MCollective
|
||||
|
||||
tempfile_storage='/mnt/tempfiles'
|
||||
|
||||
begin
|
||||
File.open('/proc/sys/kernel/panic','w') { |file| file.write("5\n") }
|
||||
#Enable sysrq trigger for further hard reboot
|
||||
File.open('/proc/sys/kernel/sysrq','w') { |file| file.write("1\n") }
|
||||
get_boot_devices.each do |dev|
|
||||
erase_data(dev[:name])
|
||||
erase_data(dev[:name], 1, dev[:size], '512')
|
||||
end unless dry_run
|
||||
|
||||
reply[:erased] = true
|
||||
rescue Exception => e
|
||||
reply[:erased] = false
|
||||
reply[:status] += 1
|
||||
msg = "MBR can't be erased. Reason: #{e.message};"
|
||||
Log.error(msg)
|
||||
error_msg << msg
|
||||
end
|
||||
|
||||
begin
|
||||
reboot if !dry_run && request_reboot
|
||||
reply[:rebooted] = request_reboot
|
||||
@ -105,17 +87,48 @@ module MCollective
|
||||
|
||||
def reboot
|
||||
pid = fork do
|
||||
#Use sysrq trigger: Umount->Sync->reBoot
|
||||
debug_msg("Run node rebooting command using 'SB' to sysrq-trigger")
|
||||
sleep 5
|
||||
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")}
|
||||
['b'].each do |req|
|
||||
File.open('/proc/sysrq-trigger','w') do |file|
|
||||
file.write("#{req}\n")
|
||||
|
||||
trap('SIGTERM') do
|
||||
#Giving 5 seconds for other process to die nicely
|
||||
sleep 5
|
||||
|
||||
#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
|
||||
get_boot_devices.each do |dev|
|
||||
erase_data(dev[:name])
|
||||
erase_data(dev[:name], 1, dev[:size], '512')
|
||||
end
|
||||
|
||||
reply[:erased] = true
|
||||
rescue Exception => e
|
||||
reply[:erased] = false
|
||||
reply[:status] += 1
|
||||
msg = "MBR can't be erased. Reason: #{e.message};"
|
||||
Log.error(msg)
|
||||
error_msg << msg
|
||||
end
|
||||
|
||||
['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")}
|
||||
end
|
||||
Process.detach(pid)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user