Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8SPXC-1222: Remove state check for 5.7 #1915

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions build/pxc-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
elif [ "${!fileVar:-}" ]; then
val="$(<"${!fileVar}")"
elif [ "${3:-}" ] && [ -f "/etc/mysql/mysql-users-secret/$3" ]; then
val="$(</etc/mysql/mysql-users-secret/$3)"

Check notice on line 44 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L44 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./build/pxc-entrypoint.sh:44:41: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
fi
export "$var"="$val"
unset "$fileVar"
Expand All @@ -60,7 +60,7 @@
case "$f" in
*.sh)
echo "$0: running $f"
. "$f"

Check warning on line 63 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L63 <ShellCheck.SC1090>

ShellCheck can't follow non-constant source. Use a directive to specify location.
Raw output
./build/pxc-entrypoint.sh:63:5: warning: ShellCheck can't follow non-constant source. Use a directive to specify location. (ShellCheck.SC1090)
;;
*.sql)
echo "$0: running $f"
Expand Down Expand Up @@ -248,7 +248,7 @@
i=$(curl "$DISCOVERY_SERVICE/v2/keys/pxc-cluster/queue/$CLUSTER_NAME" | jq -r '.node.nodes[].value')

# this remove my ip from the list
i1="${i[@]//$NODE_IP/}"

Check warning on line 251 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L251 <ShellCheck.SC2124>

Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
Raw output
./build/pxc-entrypoint.sh:251:5: warning: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. (ShellCheck.SC2124)

# Register the current IP in the discovery service
# key set to expire in 30 sec. There is a cronjob that should update them regularly
Expand All @@ -258,8 +258,8 @@

i=$(curl "$DISCOVERY_SERVICE/v2/keys/pxc-cluster/$CLUSTER_NAME/?quorum=true" | jq -r '.node.nodes[]?.key' | awk -F'/' '{print $(NF)}')
# this remove my ip from the list
i2="${i[@]//$NODE_IP/}"

Check warning on line 261 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L261 <ShellCheck.SC2124>

Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
Raw output
./build/pxc-entrypoint.sh:261:5: warning: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. (ShellCheck.SC2124)
CLUSTER_JOIN=$(join , $i1 $i2)

Check notice on line 262 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L262 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./build/pxc-entrypoint.sh:262:24: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

Check notice on line 262 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L262 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./build/pxc-entrypoint.sh:262:28: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)

sed -r "s|^[#]?wsrep_node_address=.*$|wsrep_node_address=${NODE_IP}|" "${CFG}" 1<>"${CFG}"
sed -r "s|^[#]?wsrep_cluster_name=.*$|wsrep_cluster_name=${CLUSTER_NAME}|" "${CFG}" 1<>"${CFG}"
Expand Down Expand Up @@ -300,7 +300,7 @@

# if we have CLUSTER_JOIN - then we do not need to perform datadir initialize
# the data will be copied from another node
if [ -z "$CLUSTER_JOIN" ] && [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

Check warning on line 303 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L303 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:303:48: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
# still need to check config, container may have started with --user
_check_config "$@"

Expand All @@ -313,7 +313,7 @@
if [ ! -d "$DATADIR/mysql" ]; then
file_env 'MYSQL_ROOT_PASSWORD' '' 'root'
{ set +x; } 2>/dev/null
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then

Check warning on line 316 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L316 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:316:34: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)

Check warning on line 316 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L316 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:316:70: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
echo >&2 'error: database is uninitialized and password option is not specified '
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
exit 1
Expand Down Expand Up @@ -369,7 +369,7 @@
fi

{ set +x; } 2>/dev/null
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then

Check notice on line 372 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L372 <ShellCheck.SC2236>

Use -n instead of ! -z.
Raw output
./build/pxc-entrypoint.sh:372:8: info: Use -n instead of ! -z. (ShellCheck.SC2236)
MYSQL_ROOT_PASSWORD="$(pwmake 128)"
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
fi
Expand All @@ -377,7 +377,7 @@
rootCreate=
# default root to listen for connections from anywhere
file_env 'MYSQL_ROOT_HOST' '%'
if [ ! -z "$MYSQL_ROOT_HOST" -a "$MYSQL_ROOT_HOST" != 'localhost' ]; then

Check notice on line 380 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L380 <ShellCheck.SC2236>

Use -n instead of ! -z.
Raw output
./build/pxc-entrypoint.sh:380:8: info: Use -n instead of ! -z. (ShellCheck.SC2236)

Check warning on line 380 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L380 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:380:32: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
# no, we don't care if read finds a terminating character in this heredoc
# https://unix.stackexchange.com/questions/265149/why-is-set-o-errexit-breaking-this-read-heredoc-expression/265151#265151
read -r -d '' rootCreate <<-EOSQL || true
Expand Down Expand Up @@ -434,7 +434,7 @@
EOSQL

{ set +x; } 2>/dev/null
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then

Check notice on line 437 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L437 <ShellCheck.SC2236>

Use -n instead of ! -z.
Raw output
./build/pxc-entrypoint.sh:437:8: info: Use -n instead of ! -z. (ShellCheck.SC2236)
mysql+=(-p"${MYSQL_ROOT_PASSWORD}")
fi
set -x
Expand All @@ -448,7 +448,7 @@
file_env 'MYSQL_USER'
file_env 'MYSQL_PASSWORD'
{ set +x; } 2>/dev/null
if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then

Check warning on line 451 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L451 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:451:22: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"

if [ "$MYSQL_DATABASE" ]; then
Expand All @@ -466,7 +466,7 @@
done

{ set +x; } 2>/dev/null
if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then

Check notice on line 469 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L469 <ShellCheck.SC2236>

Use -n instead of ! -z.
Raw output
./build/pxc-entrypoint.sh:469:8: info: Use -n instead of ! -z. (ShellCheck.SC2236)
"${mysql[@]}" <<-EOSQL
ALTER USER 'root'@'%' PASSWORD EXPIRE;
EOSQL
Expand All @@ -483,13 +483,13 @@
fi

# exit when MYSQL_INIT_ONLY environment variable is set to avoid starting mysqld
if [ ! -z "$MYSQL_INIT_ONLY" ]; then

Check notice on line 486 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L486 <ShellCheck.SC2236>

Use -n instead of ! -z.
Raw output
./build/pxc-entrypoint.sh:486:7: info: Use -n instead of ! -z. (ShellCheck.SC2236)
echo 'Initialization complete, now exiting!'
exit 0
fi
fi

if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

Check warning on line 492 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L492 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:492:22: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
# still need to check config, container may have started with --user
_check_config "$@"

Expand All @@ -504,37 +504,29 @@
pxc_version=''
if [ -f "$DATADIR/version_info" ]; then
pxc_version_file="$DATADIR/version_info"
pxc_version=$(cat "$pxc_version_file" | awk '{print $3}')

Check notice on line 507 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L507 <ShellCheck.SC2002>

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
Raw output
./build/pxc-entrypoint.sh:507:21: info: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. (ShellCheck.SC2002)
elif [ -f "$DATADIR/xtrabackup_info" ]; then
pxc_version_file="$DATADIR/xtrabackup_info"
pxc_version=$(grep 'server_version' "$pxc_version_file" | awk '{print $3}' | tr -d '\n')
fi

if [[ -f $pxc_version_file && -n $pxc_version && $MYSQL_VERSION == '5.7' ]] && [[ $(cat /tmp/version_info) != $pxc_version ]]; then

Check warning on line 513 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L513 <ShellCheck.SC2053>

Quote the right-hand side of != in [[ ]] to prevent glob matching.
Raw output
./build/pxc-entrypoint.sh:513:112: warning: Quote the right-hand side of != in [[ ]] to prevent glob matching. (ShellCheck.SC2053)
SOCKET="$(_get_config 'socket' "$@")"
"$@" --skip-networking --socket="${SOCKET}" --wsrep-provider='none' &
pid="$!"

mysql=(mysql --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" --password="")
{ set +x; } 2>/dev/null
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then

Check notice on line 520 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L520 <ShellCheck.SC2236>

Use -n instead of ! -z.
Raw output
./build/pxc-entrypoint.sh:520:8: info: Use -n instead of ! -z. (ShellCheck.SC2236)
mysql+=(-p"${MYSQL_ROOT_PASSWORD}")
fi
set -x

if [[ "$MYSQL_VERSION" =~ ^(8\.0|8\.4)$ ]]; then
mysqlState="startup"
while [[ "${mysqlState}" != "ready" ]]; do
mysqlState=$(tr -d '\0' < ${MYSQL_STATE_FILE})
echo >&2 "MySQL upgrade process in progress..."
sleep 1
done
fi
for i in {120..0}; do
if echo 'SELECT 1' | "${mysql[@]}" &>/dev/null; then
break
fi

echo >&2 "MySQL upgrade process in progress..."
sleep 1
done
if [ "$i" = 0 ]; then
Expand All @@ -555,16 +547,16 @@
POD_NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)

wsrep_start_position_opt=""
if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then

Check warning on line 550 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L550 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:550:22: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
DATADIR="$(_get_config 'datadir' "$@")"
grastate_loc="${DATADIR}/grastate.dat"
wsrep_verbose_logfile="$DATADIR/wsrep_recovery_verbose.log"
if [ -f "$wsrep_verbose_logfile" ]; then
cat "$wsrep_verbose_logfile" | tee -a "$DATADIR/wsrep_recovery_verbose_history.log"

Check notice on line 555 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L555 <ShellCheck.SC2002>

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
Raw output
./build/pxc-entrypoint.sh:555:7: info: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. (ShellCheck.SC2002)
rm -f "$wsrep_verbose_logfile"
fi

if [ -s "$grastate_loc" -a -d "$DATADIR/mysql" ]; then

Check warning on line 559 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L559 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:559:26: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
uuid=$(grep 'uuid:' "$grastate_loc" | cut -d: -f2 | tr -d ' ' || :)
seqno=$(grep 'seqno:' "$grastate_loc" | cut -d: -f2 | tr -d ' ' || :)
safe_to_bootstrap=$(grep 'safe_to_bootstrap:' "$grastate_loc" | cut -d: -f2 | tr -d ' ' || :)
Expand All @@ -579,11 +571,11 @@
fi
fi

if [ -z "$wsrep_start_position_opt" -a -d "$DATADIR/mysql" ]; then

Check warning on line 574 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L574 <ShellCheck.SC2166>

Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Raw output
./build/pxc-entrypoint.sh:574:38: warning: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. (ShellCheck.SC2166)
"$@" --wsrep_recover --log-error-verbosity=3 --log_error="$wsrep_verbose_logfile"

echo >&2 "WSREP: Print recovery logs: "
cat "$wsrep_verbose_logfile" | tee -a "$DATADIR/wsrep_recovery_verbose_history.log"

Check notice on line 578 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L578 <ShellCheck.SC2002>

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
Raw output
./build/pxc-entrypoint.sh:578:7: info: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. (ShellCheck.SC2002)
if grep ' Recovered position:' "$wsrep_verbose_logfile"; then
start_pos="$(
grep ' Recovered position:' "$wsrep_verbose_logfile" |
Expand Down Expand Up @@ -620,7 +612,7 @@
sed -i 's/safe_to_bootstrap: 0/safe_to_bootstrap: 1/g' "$grastate_loc"
fi
echo "Recovery was finished."
exec "$@" $wsrep_start_position_opt

Check notice on line 615 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L615 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./build/pxc-entrypoint.sh:615:14: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
}
function is_manual_recovery() {
set +o xtrace
Expand Down Expand Up @@ -673,7 +665,7 @@
fi
fi

test -e /opt/percona/hookscript/hook.sh && source /opt/percona/hookscript/hook.sh

Check notice on line 668 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L668 <ShellCheck.SC1091>

Not following: /opt/percona/hookscript/hook.sh was not specified as input (see shellcheck -x).
Raw output
./build/pxc-entrypoint.sh:668:51: info: Not following: /opt/percona/hookscript/hook.sh was not specified as input (see shellcheck -x). (ShellCheck.SC1091)

init_opt=""
if [[ -f /etc/mysql/init-file/init.sql ]]; then
Expand All @@ -681,4 +673,4 @@
echo "Using init-file: /etc/mysql/init-file/init.sql"
fi

exec "$@" ${wsrep_start_position_opt} ${init_opt}

Check notice on line 676 in build/pxc-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/pxc-entrypoint.sh#L676 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./build/pxc-entrypoint.sh:676:11: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
Loading