From db5b9ee83417d44331d63b3d0100c2952a885144 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Fri, 15 Jan 2021 07:48:11 -0800 Subject: [PATCH] [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 --- .../warmboot-finalizer/finalize-warmboot.sh | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/files/image_config/warmboot-finalizer/finalize-warmboot.sh b/files/image_config/warmboot-finalizer/finalize-warmboot.sh index 01ad921137..08be9861a6 100755 --- a/files/image_config/warmboot-finalizer/finalize-warmboot.sh +++ b/files/image_config/warmboot-finalizer/finalize-warmboot.sh @@ -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/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() { WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable` @@ -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} @@ -86,13 +107,17 @@ if [[ x"${WARM_BOOT}" != x"true" ]]; then exit 0 fi -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