Kill hung frame listeners on each verify networks event
Network checker relies on interrupt signal for its own internal logic, so after interrupt is received - it will do some parsing work and wont finish immediatly. But before starting frame listeners in a new run - old frame listeners may be not interrupted because mcollective failed due timeout or any other not predicted problem. So, we need to completely shutdown frame listeners with kill -9 Tested: Spawned bunch of - /usr/bin/python /usr/bin/net_probe.py -c listen.conf Executed network verification from UI - all old listeners were killed, verification succeeded. Also, executed same test with removed pid files in /var/run/net_probe folder Change-Id: I7aa48d00b3f86827ba9860a3e3797ed5bd0eb713 Closes-Bug: 1466020
This commit is contained in:
parent
776157f722
commit
7fff2f88a6
|
@ -22,6 +22,7 @@ module MCollective
|
||||||
class Net_probe<RPC::Agent
|
class Net_probe<RPC::Agent
|
||||||
def startup_hook
|
def startup_hook
|
||||||
@pattern = "/var/tmp/net-probe-dump*"
|
@pattern = "/var/tmp/net-probe-dump*"
|
||||||
|
@piddir = '/var/run/net_probe'
|
||||||
end
|
end
|
||||||
|
|
||||||
action "multicast_listen" do
|
action "multicast_listen" do
|
||||||
|
@ -42,7 +43,7 @@ module MCollective
|
||||||
end
|
end
|
||||||
|
|
||||||
action "start_frame_listeners" do
|
action "start_frame_listeners" do
|
||||||
cleanup_netprobe
|
kill_frame_listeners
|
||||||
start_frame_listeners
|
start_frame_listeners
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -99,11 +100,6 @@ module MCollective
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_netprobe
|
|
||||||
status = run("pkill net_probe.py && sleep 2 && pgrep net_probe.py")
|
|
||||||
reply.fail! "Cant stop net_probe.py execution." unless status == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
def start_frame_listeners
|
def start_frame_listeners
|
||||||
validate :interfaces, String
|
validate :interfaces, String
|
||||||
config = {
|
config = {
|
||||||
|
@ -118,9 +114,6 @@ module MCollective
|
||||||
config.merge!(JSON.parse(request[:config]))
|
config.merge!(JSON.parse(request[:config]))
|
||||||
end
|
end
|
||||||
|
|
||||||
# we want to be sure that there is no frame listeners running
|
|
||||||
stop_frame_listeners
|
|
||||||
|
|
||||||
# wipe out old stuff before start
|
# wipe out old stuff before start
|
||||||
Dir.glob(@pattern).each do |file|
|
Dir.glob(@pattern).each do |file|
|
||||||
File.delete file
|
File.delete file
|
||||||
|
@ -202,9 +195,23 @@ module MCollective
|
||||||
f
|
f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def kill_frame_listeners
|
||||||
|
net_probe_pattern = 'net_probe.py'
|
||||||
|
|
||||||
|
Dir.glob('/proc/[0-9]*/cmdline').each do |proc|
|
||||||
|
if File.read(proc).include? net_probe_pattern
|
||||||
|
Process.kill('KILL', proc.split('/')[2].to_i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# and wipe out all old pidfiles
|
||||||
|
Dir.glob(File.join(@piddir, '*')).each do |pidfile|
|
||||||
|
File.unlink(pidfile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def stop_frame_listeners
|
def stop_frame_listeners
|
||||||
piddir = "/var/run/net_probe"
|
pidfiles = Dir.glob(File.join(@piddir, '*'))
|
||||||
pidfiles = Dir.glob(File.join(piddir, '*'))
|
|
||||||
# Send SIGINT to all PIDs in piddir.
|
# Send SIGINT to all PIDs in piddir.
|
||||||
pidfiles.each do |f|
|
pidfiles.each do |f|
|
||||||
begin
|
begin
|
||||||
|
@ -226,7 +233,7 @@ module MCollective
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pidfiles = Dir.glob(File.join(piddir, '*'))
|
pidfiles = Dir.glob(File.join(@piddir, '*'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue