Skip to content

Commit

Permalink
fix: check length of master host for mysql5 (#1475)
Browse files Browse the repository at this point in the history
(cherry picked from commit 23f349d)
  • Loading branch information
hanguobiao committed Feb 20, 2025
1 parent 52760fc commit 28dfa7e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/mysql/scripts/init-mysql-instance-for-orc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ setup_master_slave() {
# If the master_pod_name is not empty, change master to the master_pod_name.
else
mysql_note "Wait for master to be ready"
change_master "$master_pod_name.${CLUSTER_COMPONENT_NAME}-headless.${CLUSTER_NAMESPACE}.svc.cluster.local"
change_master "$master_pod_name.${CLUSTER_COMPONENT_NAME}-headless"
fi
return 0
}
Expand Down
6 changes: 5 additions & 1 deletion addons/mysql/scripts/mysql-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
self_last_digit=${POD_NAME##*-}
fqdn_name=${CLUSTER_COMPONENT_NAME}-${self_last_digit}.${CLUSTER_COMPONENT_NAME}-headless.${CLUSTER_NAMESPACE}.svc.cluster.local
fqdn_name=${CLUSTER_COMPONENT_NAME}-${self_last_digit}.${CLUSTER_COMPONENT_NAME}-headless
if [ ${#fqdn_name} -gt 60 ] && [ "${MYSQL_MAJOR}" = "5.7" ]; then
echo "Error: The length of the variable exceeds 60 characters"
exit 1
fi
SERVICE_ID=$((${POD_NAME##*-} + 1))
if [ "${MYSQL_MAJOR}" = '5.7' ]; then
/scripts/docker-entrypoint.sh mysqld --server-id $SERVICE_ID --report-host ${fqdn_name} \
Expand Down
2 changes: 1 addition & 1 deletion addons/mysql/scripts/mysql-orchestrator-register.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ register_first_mysql_instance() {
IFS=',' read -r -a replicas <<< "${MYSQL_POD_FQDN_LIST}"
fqdn_name=${replicas[0]}
last_digit=${fqdn_name##*-}
first_mysql_instance=${CLUSTER_COMPONENT_NAME}-${last_digit}.${CLUSTER_COMPONENT_NAME}-headless.${CLUSTER_NAMESPACE}.svc.cluster.local
first_mysql_instance=${CLUSTER_COMPONENT_NAME}-${last_digit}.${CLUSTER_COMPONENT_NAME}-headless
register_to_orchestrator "$first_mysql_instance"

echo "Initialization script completed!"
Expand Down

0 comments on commit 28dfa7e

Please sign in to comment.