Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[warm reboot] Skip ASIC config pre-check if current image does not support it #637

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions scripts/asic_config_check
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Exit codes
ASIC_CONFIG_UNCHANGED=0
ASIC_CONFIG_CHANGED=1
SRC_ASIC_CONFIG_NOT_FOUND=2
CURR_ASIC_CONFIG_NOT_FOUND=2
DST_ASIC_CONFIG_NOT_FOUND=3

# Logging utilities
Expand All @@ -17,14 +17,16 @@ function debug()
logger -p user.info "$@"
}

# Retrieve the source ASIC config checksum from the source image
# Exits with error SRC_ASIC_CONFIG_NOT_FOUND if the checksum is not found
function GetSourceASICConfigChecksum()
# Retrieve the current ASIC config checksum from the current image
# Returns CURR_ASIC_CONFIG_NOT_FOUND if the checksum is not found, ASIC_CONFIG_UNCHANGED otherwise
function GetCurrentASICConfigChecksum()
{
if [[ ! -f "/etc/sonic/asic_config_checksum" ]]; then
error "ASIC config not found in src image, can't verify changes"
exit "${SRC_ASIC_CONFIG_NOT_FOUND}"
debug "ASIC config not found in curr image, pre-check not supported"
return "${CURR_ASIC_CONFIG_NOT_FOUND}"
yxieca marked this conversation as resolved.
Show resolved Hide resolved
fi

return "${ASIC_CONFIG_UNCHANGED}"
}
yxieca marked this conversation as resolved.
Show resolved Hide resolved

# Retrieve the destination ASIC config checksum from the destination image
Expand Down Expand Up @@ -56,13 +58,13 @@ function GetDestinationASICConfigChecksum()
rm -rf "${FS_MOUNTPOINT}"
}

# Confirm that the src and dst ASIC config checksums match
# Confirm that the curr and dst ASIC config checksums match
# Exits with ASIC_CONFIG_CHANGED if the checksums differ
function ConfirmASICConfigChecksumsMatch()
{
SRC_CONFIG_CHECKSUM=$(cat /etc/sonic/asic_config_checksum)
CURR_CONFIG_CHECKSUM=$(cat /etc/sonic/asic_config_checksum)
DST_CONFIG_CHECKSUM=$(cat /tmp/dst_asic_config_checksum)
if [[ "${SRC_CONFIG_CHECKSUM}" != "${DST_CONFIG_CHECKSUM}" ]]; then
if [[ "${CURR_CONFIG_CHECKSUM}" != "${DST_CONFIG_CHECKSUM}" ]]; then
error "ASIC config may have changed, checksum failed"
exit "${ASIC_CONFIG_CHANGED}"
fi
Expand All @@ -71,14 +73,21 @@ function ConfirmASICConfigChecksumsMatch()
# Main starts here
debug "Checking that ASIC configuration has not changed"

SRC_SONIC_IMAGE="$(sonic_installer list | grep "Current: " | cut -f2 -d' ')"
CURR_SONIC_IMAGE="$(sonic_installer list | grep "Current: " | cut -f2 -d' ')"
DST_SONIC_IMAGE="$(sonic_installer list | grep "Next: " | cut -f2 -d' ')"
if [[ "${SRC_SONIC_IMAGE}" == "${DST_SONIC_IMAGE}" ]]; then
debug "ASIC config unchanged, src and dst SONiC version are the same"
if [[ "${CURR_SONIC_IMAGE}" == "${DST_SONIC_IMAGE}" ]]; then
debug "ASIC config unchanged, current and destination SONiC version are the same"
exit "${ASIC_CONFIG_UNCHANGED}"
fi

GET_CURR_CHECKSUM_RESULT=0
GetCurrentASICConfigChecksum || GET_CURR_CHECKSUM_RESULT=$?

# If the current device does not have a checksum then this check is not yet supported on this device
if [[ "${GET_CURR_CHECKSUM_RESULT}" == "${CURR_ASIC_CONFIG_NOT_FOUND}" ]]; then
exit "${ASIC_CONFIG_UNCHANGED}"
fi

GetSourceASICConfigChecksum
GetDestinationASICConfigChecksum
ConfirmASICConfigChecksumsMatch

Expand Down