Add conditional around the pid clean up process

The NS metadata proxy pid cleanup process hunts for and removes
PIDs executing old code by using version tags. Under certain
conditions it's possible for an old PID to have expired before
the cleanup action has run. This change simply wraps the
`pkill` command with a test to ensure the task isn't failing.
Should a PID actually be cleaned up the task will print to stdout
and log using the logger command.

Closes-Bug: #1627185
Change-Id: I8c012feb399f8ca65172e9404b859c8f6111de35
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
(cherry picked from commit cfb341a368)
This commit is contained in:
Kevin Carter 2016-09-27 11:53:17 -05:00 committed by Jesse Pretorius (odyssey4me)
parent 5764e6c8cb
commit be35547641
1 changed files with 3 additions and 1 deletions

View File

@ -35,7 +35,9 @@
for ns_pid in $(pgrep neutron-ns-meta); do
echo $(readlink -f "/proc/$ns_pid/exe") | grep -qv "{{ neutron_venv_tag }}"
if [ $? -eq 0 ]; then
(echo "old metadata proxy pid found running clean up on $ns_pid"; kill -9 "$ns_pid")
if kill -9 "$ns_pid"; then
logger -s "old metadata proxy pid found and has been cleaned up on: \"$ns_pid\""
fi
fi
done
when: neutron_services['neutron-metadata-agent'].service_en | bool