[warm boot finalizer] only wait for enabled components to reconcile (#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>
This commit is contained in:
Ying Xie 2021-01-15 07:48:11 -08:00 committed by Abhishek Dosi
parent 17c9648c9c
commit db5b9ee834

View File

@ -2,8 +2,15 @@
VERBOSE=no VERBOSE=no
# Check components # Define components that needs to reconcile during warm
COMP_LIST="orchagent neighsyncd bgp natsyncd" # 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" EXP_STATE="reconciled"
ASSISTANT_SCRIPT="/usr/bin/neighbor_advertiser" ASSISTANT_SCRIPT="/usr/bin/neighbor_advertiser"
@ -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() function check_warm_boot()
{ {
WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable` WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
@ -53,9 +74,9 @@ function check_list()
RET_LIST='' RET_LIST=''
for comp in $@; do for comp in $@; do
state=`get_component_state ${comp}` state=`get_component_state ${comp}`
if [[ x"${state}" != x"${EXP_STATE}" ]]; then if [[ x"${state}" != x"${EXP_STATE}" ]]; then
RET_LIST="${RET_LIST} ${comp}" RET_LIST="${RET_LIST} ${comp}"
fi fi
done done
echo ${RET_LIST} echo ${RET_LIST}
@ -86,13 +107,17 @@ if [[ x"${WARM_BOOT}" != x"true" ]]; then
exit 0 exit 0
fi fi
list=${COMP_LIST} get_component_list
debug "Waiting for components: '${COMPONENT_LIST}' to reconcile ..."
list=${COMPONENT_LIST}
# Wait up to 5 minutes # Wait up to 5 minutes
for i in `seq 60`; do for i in `seq 60`; do
list=`check_list ${list}` list=`check_list ${list}`
if [[ -z "${list}" ]]; then if [[ -z "${list}" ]]; then
break break
fi fi
sleep 5 sleep 5
done done