From 0e83acbbde1fa9d2f01fa560335258c9693a27f9 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Wed, 2 Sep 2020 10:40:31 -0600 Subject: [PATCH] [TRAIN-Only] Add healthcheck debug flag This is a partial cherry-pick of d03401438c22e59d4f51cedfd0af6d7d48328d45 due the other changes in that commit included more complex changes which needed further patches to address issues. This change adds a HEALTHCHECK_DEBUG environment variable to the common health check script to allow a user to enable debug verbosity when executing a health check. By default this will be off which should reduce the amount of logging generated by the container healthchecks. In order to get verbose mode when running the healthcheck directly, you can do as follow: podman exec -u root -ti bash HEALTHCHECK_DEBUG=1 ./openstack/healthcheck or podman -u root -e "HEALTHCHECK_DEBUG=1" /openstack/healthcheck and enjoy a nice debug output. Closes-Bug: #1893972 Change-Id: Ia15bca89261fecc857afef13680b05aba77fc8de --- healthcheck/common.sh | 9 ++++++++- .../notes/healthcheck-debug-0fbcfebd9042720c.yaml | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/healthcheck-debug-0fbcfebd9042720c.yaml diff --git a/healthcheck/common.sh b/healthcheck/common.sh index a702e8f2b..a6f1bf23e 100755 --- a/healthcheck/common.sh +++ b/healthcheck/common.sh @@ -1,5 +1,12 @@ #!/bin/bash -set -euxo pipefail +set -euo pipefail +: ${HEALTHCHECK_DEBUG:=0} +if [ $HEALTHCHECK_DEBUG -ne 0 ]; then + set -x + exec 3>&1 +else + exec 3>/dev/null +fi : ${HEALTHCHECK_CURL_MAX_TIME:=10} : ${HEALTHCHECK_CURL_USER_AGENT:=curl-healthcheck} : ${HEALTHCHECK_CURL_WRITE_OUT:='\n%{http_code} %{remote_ip}:%{remote_port} %{time_total} seconds\n'} diff --git a/releasenotes/notes/healthcheck-debug-0fbcfebd9042720c.yaml b/releasenotes/notes/healthcheck-debug-0fbcfebd9042720c.yaml new file mode 100644 index 000000000..05bce564a --- /dev/null +++ b/releasenotes/notes/healthcheck-debug-0fbcfebd9042720c.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Introduce new HEALTHCHECK_DEBUG variable in order to toggle verbosity, + defaults to 0 (no verbosity). Setting it to 1 will activate -x flag, + among other things.