Fix port health check false negatives

Most of the opened port health checks are failing because containers
are not run under root user. This patch makes it to avoid use of lsof
so that all containers are checked correctly on opened ports.

Closes-bug: #1714077
Co-Authored-By: Derek Higgins <derekh@redhat.com>
Change-Id: I01389ce87f81486fd887d71e6816df76276011e0
(cherry picked from commit 9671a1d80f)
This commit is contained in:
Martin Mágr 2017-08-25 11:20:48 +02:00 committed by Emilien Macchi
parent 2517e1ef81
commit a6b4a86513
1 changed files with 10 additions and 6 deletions

View File

@ -12,13 +12,17 @@ healthcheck_curl () {
healthcheck_port () {
process=$1
shift 1
port_args=()
for arg in "$@"; do
port_args+=("-i" "tcp:${arg}")
done
lsof +c0 -nP "${port_args[@]}" | awk '{print $1}' | grep -q "^${process}$"
# ss truncate command name to 15 characters and this behaviour
# cannot be diabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
shift 1
args=$@
ports=${args// /|}
ss -ntp | awk '{print $5,"-",$6}' | egrep ":($ports)" | grep "$process"
}
get_config_val () {