Skip to content

Commit

Permalink
healthcheck.sh --connect large noise in error log
Browse files Browse the repository at this point in the history
The --connect test does a tcp connection. There is no
mysql@::1 or mysql@127.0.0.1 user created so the access
is denied, but the healtcheck is correct.

The entries in the error log because of the default
log_warnings=2.

To avoid hitting max_connect_errors (default 100), a non-connection
way is to look at the proc status for listening sockets.

While normally not a direct correlation to a connection, mariadb
listens and is followed by accepting connections immedately without
anything that can fail inbetween.

We move the previous connect to mariadb_connect for compatibility
if users want to continue with that mechanism. We pre-emtively create
tcp listen as a mechanism and redirect connect to that.

Closes MariaDB#430
  • Loading branch information
grooverdan committed May 9, 2022
1 parent 942cd53 commit 003ee86
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 10.6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ARG MARIADB_MAJOR=10.6
ENV MARIADB_MAJOR $MARIADB_MAJOR
ARG MARIADB_VERSION=1:10.6.7+maria~focal
ENV MARIADB_VERSION $MARIADB_VERSION
# release-status:Stable
# release-status:Old Stable
# (https://downloads.mariadb.org/rest-api/mariadb/)

# Allowing overriding of REPOSITORY, a URL that includes suite and component for testing and Enterprise Versions
Expand Down
25 changes: 24 additions & 1 deletion 10.6/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
# Some tests require SQL privileges.
#
# TEST MINIMUM GRANTS REQUIRED
# connect none*
# tcp_connect none
# connect none
# mariadb_connect none*
# innodb_initialized USAGE
# innodb_buffer_pool_loaded USAGE
# galera_online USAGE
Expand Down Expand Up @@ -46,13 +48,34 @@ _process_sql()

# TESTS

# TCP_LISTENING
#
# Test if the pid 1, the final mariadbd process, has any TCP ports
# listening. The listening occurs immediately before the accepting of
# connections in the MariaDB server so be adequate as a healthcheck.
# The exception to this if the MariaDB container is started by some form of
# socket activation.
tcp_listening()
{
[ "$(lsof -t -p 1 -a -iTCP -sTCP:LISTEN)" = 1 ]
}

# CONNECT
#
# Tests that a connection can be made over TCP, the final state
# of the entrypoint and is listening. The authentication used
# isn't tested.
connect()
{
tcp_listening
}

# MARIADB_CONNECT
#
# Test that the connection isn't refused by the server using the mariadb client.
# Note: this was formerly connect, but generated frequent Access Denied errors
# in the container log.
mariadb_connect()
{
set +e +o pipefail
mariadb ${nodefaults:+--no-defaults} \
Expand Down
25 changes: 24 additions & 1 deletion healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
# Some tests require SQL privileges.
#
# TEST MINIMUM GRANTS REQUIRED
# connect none*
# tcp_connect none
# connect none
# mariadb_connect none*
# innodb_initialized USAGE
# innodb_buffer_pool_loaded USAGE
# galera_online USAGE
Expand Down Expand Up @@ -46,13 +48,34 @@ _process_sql()

# TESTS

# TCP_LISTENING
#
# Test if the pid 1, the final mariadbd process, has any TCP ports
# listening. The listening occurs immediately before the accepting of
# connections in the MariaDB server so be adequate as a healthcheck.
# The exception to this if the MariaDB container is started by some form of
# socket activation.
tcp_listening()
{
[ "$(lsof -t -p 1 -a -iTCP -sTCP:LISTEN)" = 1 ]
}

# CONNECT
#
# Tests that a connection can be made over TCP, the final state
# of the entrypoint and is listening. The authentication used
# isn't tested.
connect()
{
tcp_listening
}

# MARIADB_CONNECT
#
# Test that the connection isn't refused by the server using the mariadb client.
# Note: this was formerly connect, but generated frequent Access Denied errors
# in the container log.
mariadb_connect()
{
set +e +o pipefail
mysql ${nodefaults:+--no-defaults} \
Expand Down

0 comments on commit 003ee86

Please sign in to comment.