Merge "Make healthchecks more strict" into stable/train

This commit is contained in:
Zuul 2020-01-30 09:27:16 +00:00 committed by Gerrit Code Review
commit dcf932a47b
1 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -eo pipefail
: ${HEALTHCHECK_CURL_MAX_TIME:=10} : ${HEALTHCHECK_CURL_MAX_TIME:=10}
: ${HEALTHCHECK_CURL_USER_AGENT:=curl-healthcheck} : ${HEALTHCHECK_CURL_USER_AGENT:=curl-healthcheck}
: ${HEALTHCHECK_CURL_WRITE_OUT:='\n%{http_code} %{remote_ip}:%{remote_port} %{time_total} seconds\n'} : ${HEALTHCHECK_CURL_WRITE_OUT:='\n%{http_code} %{remote_ip}:%{remote_port} %{time_total} seconds\n'}
@ -47,7 +48,11 @@ healthcheck_port () {
# port by using "sudo -u" to get the right output. # port by using "sudo -u" to get the right output.
# Note: the privileged containers have the correct ss output with root # Note: the privileged containers have the correct ss output with root
# user; which is why we need to run with both users, as a best effort. # user; which is why we need to run with both users, as a best effort.
(ss -ntuap; sudo -u $puser ss -ntuap) | sort -u | grep -qE ":($ports).*,pid=($pids)," # https://bugs.launchpad.net/tripleo/+bug/1860556
# do ot use "-q" option for grep, since it returns 141 for some reason with
# set -o pipefail.
# See https://stackoverflow.com/questions/19120263/why-exit-code-141-with-grep-q
(ss -ntuap; sudo -u $puser ss -ntuap) | sort -u | grep -E ":($ports).*,pid=($pids),">/dev/null
} }
healthcheck_listen () { healthcheck_listen () {