Skip to content

Commit

Permalink
[warm boot finalizer] only wait for enabled components to reconcile (#…
Browse files Browse the repository at this point in the history
…6454)

* [warm boot finalizer] only wait for enabled components to reconcile

Define the component with its associated service. Only wait for components that have associated service enabled to reconcile during warm reboot.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
  • Loading branch information
yxieca committed Jan 15, 2021
1 parent 58a13b4 commit 054f5b7
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions files/image_config/warmboot-finalizer/finalize-warmboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

VERBOSE=no

# Check components
COMP_LIST="orchagent neighsyncd bgp natsyncd"
# Define components that needs to reconcile during warm
# boot:
# The key is the name of the service that the components belong to.
# The value is list of component names that will reconcile.
declare -A RECONCILE_COMPONENTS=( \
["swss"]="orchagent neighsyncd" \
["bgp"]="bgp" \
["nat"]="natsyncd" \
)
EXP_STATE="reconciled"

ASSISTANT_SCRIPT="/usr/local/bin/neighbor_advertiser"
Expand All @@ -18,6 +25,20 @@ function debug()
}


function get_component_list()
{
SVC_LIST=${!RECONCILE_COMPONENTS[@]}
COMPONENT_LIST=""
for service in ${SVC_LIST}; do
components=${RECONCILE_COMPONENTS[${service}]}
status=$(sonic-db-cli CONFIG_DB HGET "FEATURE|${service}" state)
if [[ x"${status}" == x"enabled" || x"${status}" == x"always_enabled" ]]; then
COMPONENT_LIST="${COMPONENT_LIST} ${components}"
fi
done
}


function check_warm_boot()
{
WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
Expand Down Expand Up @@ -53,9 +74,9 @@ function check_list()
RET_LIST=''
for comp in $@; do
state=`get_component_state ${comp}`
if [[ x"${state}" != x"${EXP_STATE}" ]]; then
if [[ x"${state}" != x"${EXP_STATE}" ]]; then
RET_LIST="${RET_LIST} ${comp}"
fi
fi
done

echo ${RET_LIST}
Expand Down Expand Up @@ -102,13 +123,17 @@ fi

restore_counters_folder

list=${COMP_LIST}
get_component_list

debug "Waiting for components: '${COMPONENT_LIST}' to reconcile ..."

list=${COMPONENT_LIST}

# Wait up to 5 minutes
for i in `seq 60`; do
list=`check_list ${list}`
if [[ -z "${list}" ]]; then
break
break
fi
sleep 5
done
Expand Down

0 comments on commit 054f5b7

Please sign in to comment.