From 0b11b2496d12d20fb3d4fba797b217d2ac71d66d Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Fri, 6 Sep 2019 16:43:50 -0700 Subject: [PATCH] [warm/fast reboot] provide strict option to prevent warm reboot under certain conditions (#631) - the only condition now is lack of control plane assistant. Signed-off-by: Ying Xie --- scripts/fast-reboot | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/fast-reboot b/scripts/fast-reboot index d503c755ac85..487a2d0495d7 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -9,6 +9,7 @@ REBOOT_SCRIPT_NAME=$(basename $0) REBOOT_TYPE="${REBOOT_SCRIPT_NAME}" VERBOSE=no FORCE=no +STRICT=no REBOOT_METHOD="/sbin/kexec -e" ASSISTANT_IP_LIST="" ASSISTANT_SCRIPT="/usr/bin/neighbor_advertiser" @@ -25,6 +26,7 @@ EXIT_NEXT_IMAGE_NOT_EXISTS=4 EXIT_ORCHAGENT_SHUTDOWN=10 EXIT_SYNCD_SHUTDOWN=11 EXIT_FAST_REBOOT_DUMP_FAILURE=12 +EXIT_NO_CONTROL_PLANE_ASSISTANT=20 function error() { @@ -49,13 +51,15 @@ function showHelpAndExit() echo " -k : reboot with /sbin/kexec -e [default]" echo " -x : execute script with -x flag" echo " -c : specify control plane assistant IP list" + echo " -s : strict mode: do not proceed without:" + echo " - control plane assistant IP list." exit "${EXIT_SUCCESS}" } function parseOptions() { - while getopts "vfh?rkxc:" opt; do + while getopts "vfh?rkxc:s" opt; do case ${opt} in h|\? ) showHelpAndExit @@ -78,6 +82,9 @@ function parseOptions() c ) ASSISTANT_IP_LIST=${OPTARG} ;; + s ) + STRICT=yes + ;; esac done } @@ -199,6 +206,9 @@ function setup_control_plane_assistant() if [[ -n "${ASSISTANT_IP_LIST}" && -x ${ASSISTANT_SCRIPT} ]]; then debug "Setting up control plane assistant: ${ASSISTANT_IP_LIST} ..." ${ASSISTANT_SCRIPT} -s ${ASSISTANT_IP_LIST} -m set + elif [[ X"${STRICT}" == X"yes" ]]; then + debug "Strict mode: fail due to lack of control plane assistant ..." + exit ${EXIT_NO_CONTROL_PLANE_ASSISTANT} fi }