Skip to content

Commit

Permalink
[warm/fast reboot] provide strict option to prevent warm reboot under…
Browse files Browse the repository at this point in the history
… certain conditions (sonic-net#631)

- the only condition now is lack of control plane assistant.

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
  • Loading branch information
yxieca authored Sep 6, 2019
1 parent 8d0df0a commit 0b11b24
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
{
Expand All @@ -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
Expand All @@ -78,6 +82,9 @@ function parseOptions()
c )
ASSISTANT_IP_LIST=${OPTARG}
;;
s )
STRICT=yes
;;
esac
done
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 0b11b24

Please # to comment.