-
Notifications
You must be signed in to change notification settings - Fork 812
[fast-reboot] Check if ASIC config has changed before warm reboot #621
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c935c31
[fast-reboot] Check if ASIC config has changed before fast reboot
daall eec5a04
Fix formatting
daall 9610d08
Incorporate feedback
daall 69408c8
Add check for reboot type and override ability
daall 9b6e0cb
Clean up error check
daall 43c17e6
Merge branch 'master' into fast-reboot-asic-config-check
daall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| # Exit codes | ||
| ASIC_CONFIG_UNCHANGED=0 | ||
| ASIC_CONFIG_CHANGED=1 | ||
| SRC_ASIC_CONFIG_NOT_FOUND=2 | ||
| DST_ASIC_CONFIG_NOT_FOUND=3 | ||
|
|
||
| # Logging utilities | ||
| function error() | ||
| { | ||
| logger -p user.err "$@" | ||
| } | ||
|
|
||
| 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() | ||
| { | ||
| 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}" | ||
| fi | ||
| } | ||
|
|
||
| # Retrieve the destination ASIC config checksum from the destination image | ||
| # Exits with error DST_ASIC_CONFIG_NOT_FOUND if the checksum is not found | ||
| function GetDestinationASICConfigChecksum() | ||
| { | ||
| DST_IMAGE_PATH="/host/image-${DST_SONIC_IMAGE#SONiC-OS-}" | ||
| FS_PATH="${DST_IMAGE_PATH}/fs.squashfs" | ||
| FS_MOUNTPOINT="/tmp/image-${DST_SONIC_IMAGE#SONiC-OS-}-fs" | ||
|
|
||
| # Verify that the destination image exists | ||
| if [[ ! -d ${DST_IMAGE_PATH} ]]; then | ||
| error "ASIC config not found in dst image, can't verify changes" | ||
| exit "${DST_ASIC_CONFIG_NOT_FOUND}" | ||
| fi | ||
|
|
||
| mkdir "${FS_MOUNTPOINT}" | ||
| mount -t squashfs "${FS_PATH}" "${FS_MOUNTPOINT}" | ||
|
|
||
| if [[ ! -f "${FS_MOUNTPOINT}/etc/sonic/asic_config_checksum" ]]; then | ||
| error "ASIC config not found in dst image, can't verify changes" | ||
| umount "${FS_MOUNTPOINT}" | ||
| rm -rf "${FS_MOUNTPOINT}" | ||
| exit "${DST_ASIC_CONFIG_NOT_FOUND}" | ||
| fi | ||
|
|
||
| cp "${FS_MOUNTPOINT}/etc/sonic/asic_config_checksum" /tmp/dst_asic_config_checksum | ||
| umount "${FS_MOUNTPOINT}" | ||
| rm -rf "${FS_MOUNTPOINT}" | ||
| } | ||
|
|
||
| # Confirm that the src 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) | ||
| DST_CONFIG_CHECKSUM=$(cat /tmp/dst_asic_config_checksum) | ||
| if [[ "${SRC_CONFIG_CHECKSUM}" != "${DST_CONFIG_CHECKSUM}" ]]; then | ||
| error "ASIC config may have changed, checksum failed" | ||
| exit "${ASIC_CONFIG_CHANGED}" | ||
| fi | ||
| } | ||
|
|
||
| # Main starts here | ||
| debug "Checking that ASIC configuration has not changed" | ||
|
|
||
| SRC_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" | ||
| exit "${ASIC_CONFIG_UNCHANGED}" | ||
| fi | ||
|
|
||
| GetSourceASICConfigChecksum | ||
| GetDestinationASICConfigChecksum | ||
| ConfirmASICConfigChecksumsMatch | ||
|
|
||
| debug "ASIC config unchanged, checksum passed" | ||
| exit "${ASIC_CONFIG_UNCHANGED}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.