Graylog2 / graylog-docker

Official Graylog Docker image
https://hub.docker.com/r/graylog/graylog/
Apache License 2.0
367 stars 133 forks source link

healthcheck fails if `http_publish_uri` is given in config file #102

Closed padelt closed 4 years ago

padelt commented 4 years ago

(This is a slightly amended repost of a comment in #98.)

This happens with the Docker hub images graylog/graylog:3.1.2-2, graylog/graylog:3.1.2-3, graylog/graylog:3.1.3 and graylog/graylog:3.1.3-1, but does not happen with graylog/graylog:3.1.2-1:

root@graylog-master:/usr/share/graylog# grep "^http_publish_uri" "${GRAYLOG_HOME}"/data/config/graylog.conf
# Default: $http_publish_uri
http_publish_uri = http://graylog-master:9000

Instrumented run of /healtcheck.sh:

root@graylog-master:/usr/share/graylog# /health_check.sh
+ PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
+(/health_check.sh:14): proto=http
+(/health_check.sh:15): http_bind_address=127.0.0.1:9000
+(/health_check.sh:18): [[ -f /usr/share/graylog/data/config/graylog.conf ]]
++(/health_check.sh:21): grep '^http_publish_uri' /usr/share/graylog/data/config/graylog.conf
++(/health_check.sh:21): awk -F = '{print $2}'
++(/health_check.sh:21): awk '{$1=$1};1'
+(/health_check.sh:21): http_publish_uri=http://graylog-master:9000
++(/health_check.sh:22): grep '^http_bind_address' /usr/share/graylog/data/config/graylog.conf
++(/health_check.sh:22): awk -F = '{print $2}'
++(/health_check.sh:22): awk '{$1=$1};1'
+(/health_check.sh:22): http_bind_address=0.0.0.0:9000
++(/health_check.sh:23): grep '^http_enable_tls' /usr/share/graylog/data/config/graylog.conf
++(/health_check.sh:23): awk -F = '{print $2}'
++(/health_check.sh:23): awk '{$1=$1};1'
+(/health_check.sh:23): http_enable_tls=
+(/health_check.sh:29): [[ ! -z '' ]]
+(/health_check.sh:40): [[ ! -z '' ]]
+(/health_check.sh:44): [[ ! -z '' ]]
+(/health_check.sh:50): [[ ! -z '' ]]
+(/health_check.sh:55): [[ ! -z 0.0.0.0:9000 ]]
+(/health_check.sh:57): check_url=http://0.0.0.0:9000
+(/health_check.sh:65): [[ ! -z http://graylog-master:9000 ]]
+(/health_check.sh:67): check_url=http://http://graylog-master:9000
+(/health_check.sh:70): [[ -z http://http://graylog-master:9000 ]]
+(/health_check.sh:77): curl --silent --fail http://http://graylog-master:9000/api
+(/health_check.sh:81): exit 1

Note the http://http:// in the curl statement near the end. This leads to the healthcheck failing even if the API endpoint is actually OK.

From a quick look it seems https://github.com/Graylog2/graylog-docker/blob/3.1/health_check.sh#L29-L39 tries to remove the protocol part if GRAYLOG_HTTP_PUBLISH_URI is given (which it is not in my case). Later, http_publish_uri is assumed to not have the protocol part. But if it came from the config file, it will be there and the resulting check_url will have the double protocol problem.