Speedup gathering pids from namespaces by OCF
Currently, neutron OCF scripts are using `lsof` to gather pids of processes running in particular namespace. `lsof` is extremely slow due to inoptimal architecture and causes significant timeouts: 2+ minutes on 300 pids in 300 namespaces. On the other hand, we cannot use `ip netns pids`, as this command is not present in precise. The fix changes this call to the 2-stage execution inspired by the original code of `ip netns pids`, which uses comparison of the namespace inode with the `ns/net` symlink of the running process that points to the required namespace. This scales about linear: 1.7 seconds per 300 pids in 300 namespaces. Closes-Bug: #1464815 Closes-Bug: #1405477 Change-Id: Ife3f5da3558bf4b5ddd0abbe997cd4b845a8d53c
This commit is contained in:
parent
3d26c3d456
commit
b0aee5f006
|
@ -358,7 +358,8 @@ get_ns_list() {
|
|||
get_pid_list_for_ns_list() {
|
||||
# Parameters contain namespace names for searching pids
|
||||
local ns_list="$@"
|
||||
local pids=`for netns in $ns_list ; do ip netns exec $netns lsof -n -i -t ; done`
|
||||
local proc=$(find /proc/*/ns/net -exec stat -L -c%n:%i {} \; 2>/dev/null)
|
||||
local pids=$(for netns in $ns_list ; do echo "$proc" | grep `stat -L -c%i /var/run/netns/$netns` | sed -e 's/\/proc\///' -e 's/\/ns\/net.*$//' ; done)
|
||||
echo $pids
|
||||
}
|
||||
|
||||
|
|
|
@ -380,7 +380,8 @@ get_ns_list() {
|
|||
get_pid_list_for_ns_list() {
|
||||
# Parameters contain namespace names for searching pids
|
||||
local ns_list="$@"
|
||||
local pids=`for netns in $ns_list ; do ip netns exec $netns lsof -n -i -t ; done`
|
||||
local proc=$(find /proc/*/ns/net -exec stat -L -c%n:%i {} \; 2>/dev/null)
|
||||
local pids=$(for netns in $ns_list ; do echo "$proc" | grep `stat -L -c%i /var/run/netns/$netns` | sed -e 's/\/proc\///' -e 's/\/ns\/net.*$//' ; done)
|
||||
echo $pids
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue