Skip to content

Commit 77005f5

Browse files
author
SUSE Update Bot
committed
Test build for #1050
1 parent 864901a commit 77005f5

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

rmt-mariadb-image/healthcheck.sh

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,39 @@ connect()
6565
return "$s";
6666
;;
6767
esac
68-
# falling back to this if there wasn't a connection answer.
69-
set +e +o pipefail
70-
# (on second extra_file)
71-
# shellcheck disable=SC2086
72-
mariadb ${nodefaults:+--no-defaults} \
68+
# falling back to tcp if there wasn't a connection answer.
69+
s=$(mariadb ${nodefaults:+--no-defaults} \
7370
${def['file']:+--defaults-file=${def['file']}} \
7471
${def['extra_file']:+--defaults-extra-file=${def['extra_file']}} \
7572
${def['group_suffix']:+--defaults-group-suffix=${def['group_suffix']}} \
76-
-h localhost --protocol tcp -e 'select 1' 2>&1 \
77-
| grep -qF "Can't connect"
78-
local ret=${PIPESTATUS[1]}
79-
set -eo pipefail
80-
if (( "$ret" == 0 )); then
81-
# grep Matched "Can't connect" so we fail
82-
connect_s=1
83-
else
84-
connect_s=0
85-
fi
73+
-h localhost --protocol tcp \
74+
--skip-column-names --batch --skip-print-query-on-error \
75+
-e 'select @@skip_networking' 2>&1)
76+
77+
case "$s" in
78+
1) # skip-networking=1 (no network)
79+
;&
80+
ERROR\ 2002\ \(HY000\):*)
81+
# cannot connect
82+
connect_s=1
83+
;;
84+
0) # skip-networking=0
85+
;&
86+
ERROR\ 1820\ \(HY000\)*) # password expire
87+
;&
88+
ERROR\ 4151\ \(HY000\):*) # account locked
89+
;&
90+
ERROR\ 1226\ \(42000\)*) # resource limit exceeded
91+
;&
92+
ERROR\ 1[0-9][0-9][0-9]\ \(28000\):*)
93+
# grep access denied and other 28000 client errors - we did connect
94+
connect_s=0
95+
;;
96+
*)
97+
>&2 echo "Unknown error $s"
98+
connect_s=1
99+
;;
100+
esac
86101
return $connect_s
87102
}
88103

@@ -365,8 +380,8 @@ while [ $# -gt 0 ]; do
365380
fi
366381
shift
367382
done
368-
if [ -z "$connect_s" ]; then
369-
# we didn't do a connnect test, so the current success status is suspicious
383+
if [ "$connect_s" != "0" ]; then
384+
# we didn't pass a connnect test, so the current success status is suspicious
370385
# return what connect thinks.
371386
connect
372387
exit $?

0 commit comments

Comments
 (0)