diff --git a/addons/mysql/scripts/mysql-orchestrator-register.sh b/addons/mysql/scripts/mysql-orchestrator-register.sh index 00377a3fc..5eaa46373 100644 --- a/addons/mysql/scripts/mysql-orchestrator-register.sh +++ b/addons/mysql/scripts/mysql-orchestrator-register.sh @@ -1,17 +1,7 @@ #!/bin/sh set -ex -# meta mysql connection parameters -# mysql_port="3306" -# mysql_username="$MYSQL_ROOT_USER" -# mysql_password="$MYSQL_ROOT_PASSWORD" - -# topology_user="$ORC_TOPOLOGY_USER" -# topology_password="$ORC_TOPOLOGY_PASSWORD" - -# component_name="$KB_COMP_NAME" - -# register first pod to orchestrator +# register a mysql instance to orchestrator register_to_orchestrator() { local host_ip=$1 @@ -35,8 +25,6 @@ register_to_orchestrator() { exit 1 fi - # url for orchestrator to discover this host_ip - # send request to orchestrator for discovery response=$(curl -s -o /dev/null -w "%{http_code}" $url) if [ $response -eq 200 ]; then @@ -48,22 +36,11 @@ register_to_orchestrator() { echo "register $pod_name ($host_ip) to Orchestrator successful." } -# Get the svc list from the environment variable -# and get the topology information of the current cluster from the orchestrator -main() { - - if [ -z "$MSYQL_POD_NAME_LIST" ] || [ -z "$MSYQL_POD_HOST_IP_LIST" ]; then - echo "Error: Required environment variables MYSQL_POD_NAME_LIST or MSYQL_POD_HOST_IP_LIST are not set." - exit 1 - fi - - old_ifs="$IFS" - IFS=',' - pod_name_list=($MYSQL_POD_NAME_LIST) - pod_ip_list=($KB_CLUSTER_COMPONENT_POD_IP_LIST) - IFS="$old_ifs" - echo "pod_name_list: $pod_name_list" +# register the first MySQL instance to Orchestrator, +# and Orchestrator will obtain the entire MySQL cluster topology info from this instance. +register_first_mysql_instance() { + # get first MySQL instance host name. first_mysql_service_host_name=$(echo "${KB_CLUSTER_COMP_NAME}_MYSQL_0_SERVICE_HOST" | tr '-' '_' | tr '[:lower:]' '[:upper:]') first_mysql_service_host=${!first_mysql_service_host_name} @@ -71,6 +48,5 @@ main() { echo "Initialization script completed!" } -main -echo "completed" +register_first_mysql_instance