This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit a937c54b2b4a1b3da537f642ad3d27b4f2201c44
Author: FreeOnePlus <[email protected]>
AuthorDate: Mon Mar 11 22:19:53 2024 +0800

    [fix](docker)Fix the registration logic of Doris On Docker (#32026)
    
    * Refactor upgrade documentation
    
    * fix docker be entry point shell
    
    ---------
    
    Co-authored-by: Yijia Su <[email protected]>
---
 docker/runtime/be/resource/entry_point.sh | 16 +-----
 docker/runtime/be/resource/init_be.sh     | 96 ++++++++++++++-----------------
 2 files changed, 45 insertions(+), 67 deletions(-)

diff --git a/docker/runtime/be/resource/entry_point.sh 
b/docker/runtime/be/resource/entry_point.sh
index 4012ce1c2fa..1ae418163fa 100644
--- a/docker/runtime/be/resource/entry_point.sh
+++ b/docker/runtime/be/resource/entry_point.sh
@@ -62,17 +62,6 @@ docker_setup_env() {
 # Check the variables required for startup
 docker_required_variables_env() {
   declare -g RUN_TYPE
-  if [ -n "$BUILD_TYPE" ]; then
-      RUN_TYPE="K8S"
-      if [[ $BUILD_TYPE =~ ^([kK]8[sS])$ ]]; then
-          doris_warn "BUILD_TYPE" $BUILD_TYPE
-      else
-          doris_error "BUILD_TYPE rule error!example: [k8s], Default Value: 
docker"
-      fi
-      export RUN_TYPE=${RUN_TYPE}
-      return
-  fi
-
   if [[ -n "$FE_SERVERS" && -n "$BE_ADDR" ]]; then
       RUN_TYPE="ELECTION"
       if [[ $FE_SERVERS =~ 
^.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4}(,.+:[1-2]{0,1}[0-9]{0,1}[0-9]{1}(\.[1-2]{0,1}[0-9]{0,1}[0-9]{1}){3}:[1-6]{0,1}[0-9]{1,4})*$
 || $FE_SERVERS =~ 
^.+:([0-9a-fA-F]{1,4}:){7,7}([0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,6}(:[0-9a-fA-F]{1,4}|:)|([0-9a-fA-F]{1,4}:){1,5}((:[0-9a-fA-F]{1,4}){1,2}|:)|([0-9a-fA-F]{1,4}:){1,4}((:[0-9a-fA-F]{1,4}){1,3}|:)|([0-9a-fA-F]{1,4}:){1,3}((:[0-9a-fA-F]{1,4}){1,4}|:)|([0-9a-fA-F]
 [...]
@@ -110,14 +99,11 @@ docker_required_variables_env() {
       return
   fi
 
-
   doris_error EOF "
                Note that you did not configure the required parameters!
                plan 1:
-               BUILD_TYPE
-               plan 2:
                FE_SERVERS & BE_ADDR
-               plan 3:
+               plan 2:
                FE_MASTER_IP & FE_MASTER_PORT & BE_IP & BE_PORT"
               EOF
 }
diff --git a/docker/runtime/be/resource/init_be.sh 
b/docker/runtime/be/resource/init_be.sh
index 22817a39cfc..5c8a4dd0563 100644
--- a/docker/runtime/be/resource/init_be.sh
+++ b/docker/runtime/be/resource/init_be.sh
@@ -92,56 +92,53 @@ node_role_conf(){
 }
 
 register_be_to_fe() {
-  set +e
-  # check fe status
-  local is_fe_start=false
-  for i in {1..300}; do
-    docker_process_sql <<<"alter system add backend 
'${CURRENT_BE_IP}:${CURRENT_BE_PORT}'"
-    register_be_status=$?
-    if [[ $register_be_status == 0 ]]; then
-      doris_note "BE successfully registered to FE!"
-      is_fe_start=true
-      break
-    else
+    set +e
+    # check fe status
+    local is_fe_start=false
+    if [ -n "$DATABASE_ALREADY_EXISTS" ]; then
       check_be_status
       if [ -n "$BE_ALREADY_EXISTS" ]; then
         doris_warn "Same backend already exists! No need to register again!"
-        break
+        return
+      fi
+    fi
+    for i in {1..300}; do
+      docker_process_sql <<<"alter system add backend 
'${CURRENT_BE_IP}:${CURRENT_BE_PORT}'"
+      register_be_status=$?
+      if [[ $register_be_status == 0 ]]; then
+        doris_note "BE successfully registered to FE!"
+        is_fe_start=true
+        return
       fi
       if [[ $(( $i % 20 )) == 1 ]]; then
-          doris_warn "register_be_status: ${register_be_status}"
-          doris_warn "BE failed registered to FE!"
+        doris_note "Register BE to FE is failed. retry."
       fi
+      sleep 1
+    done
+    if ! [[ $is_fe_start ]]; then
+      doris_error "Failed to register BE to FE!Tried 30 times!Maybe FE Start 
Failed!"
     fi
-    if [[ $(( $i % 20 )) == 1 ]]; then
-      doris_note "Register BE to FE is failed. retry."
-    fi
-    sleep 1
-  done
-  if ! [[ $is_fe_start ]]; then
-    doris_error "Failed to register BE to FE!Tried 30 times!Maybe FE Start 
Failed!"
-  fi
 }
 
 check_be_status() {
     set +e
     local is_fe_start=false
     for i in {1..300}; do
-        if [[ $(($i % 20)) == 1 ]]; then
-            doris_warn "start check be register status~"
-        fi
-        docker_process_sql <<<"show backends;" | grep 
"[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep 
"[[:space:]]${CURRENT_BE_PORT}[[:space:]]"
-        be_join_status=$?
-        if [[ "${be_join_status}" == 0 ]]; then
-            doris_note "Verify that BE is registered to FE successfully"
-            is_fe_start=true
-            return
-        else
-            if [[ $(($i % 20)) == 1 ]]; then
-                doris_note "register is failed, wait next~"
-            fi
-        fi
-        sleep 1
+      if [[ $(($i % 20)) == 1 ]]; then
+        doris_warn "start check be register status~"
+      fi
+      docker_process_sql <<<"show backends;" | grep 
"[[:space:]]${CURRENT_BE_IP}[[:space:]]" | grep 
"[[:space:]]${CURRENT_BE_PORT}[[:space:]]"
+      be_join_status=$?
+      if [[ "${be_join_status}" == 0 ]]; then
+        doris_note "Verify that BE is registered to FE successfully"
+        is_fe_start=true
+        return
+      else
+      if [[ $(($i % 20)) == 1 ]]; then
+        doris_note "register is failed, wait next~"
+      fi
+      fi
+      sleep 1
     done
     if [[ ! $is_fe_start ]]; then
         doris_error "Failed to register BE to FE!Tried 30 times!Maybe FE Start 
Failed!"
@@ -155,22 +152,17 @@ cleanup() {
 
 _main() {
     trap 'cleanup' SIGTERM SIGINT
-    if [[ $RUN_TYPE == "K8S" ]]; then
-        start_be.sh --console &
-        child_pid=$!
-    else
-        docker_setup_env
-        if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
-          add_priority_networks $PRIORITY_NETWORKS
-          node_role_conf
-          show_be_args
-          register_be_to_fe
-        fi
-        check_be_status
-        doris_note "Ready to start BE!"
-        start_be.sh --console &
-        child_pid=$!
+    docker_setup_env
+    if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
+      add_priority_networks $PRIORITY_NETWORKS
+      node_role_conf
+      show_be_args
+      register_be_to_fe
     fi
+    check_be_status
+    doris_note "Ready to start BE!"
+    start_be.sh --console &
+    child_pid=$!
     wait $child_pid
     exec "$@"
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to