Skip to content

Commit

Permalink
fix docker be entry point shell
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeOnePlus committed Mar 9, 2024
1 parent 4fbfc41 commit 418b5e7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 67 deletions.
16 changes: 1 addition & 15 deletions docker/runtime/be/resource/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]{1,4}:){1,2}((:[0-9a-fA-F]{1,4}){1,5}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)|:((:[0-9a-fA-F]{1,4}){1,7}|:)$ ]]; then
Expand Down Expand Up @@ -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
}
Expand Down
96 changes: 44 additions & 52 deletions docker/runtime/be/resource/init_be.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand All @@ -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 "$@"
}
Expand Down

0 comments on commit 418b5e7

Please sign in to comment.