From ac0b650ebff135ed2b5d38eaa2f6bb24bcd7f6a5 Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Fri, 16 Jun 2023 01:14:52 +0300 Subject: [PATCH] [mlnx-ffb.sh] Update issu-version location (#14925) #### Why I did it ISSU version check fails due to inability to mount squashfs from 202211 on 201911 #### How I did it Put ISSU version file under platform directory #### How to verify it Warm-upgrade matrix: - 201911 (with https://github.com/sonic-net/sonic-buildimage/pull/14928) to master - 201911 (with https://github.com/sonic-net/sonic-buildimage/pull/14928) to 202211 - 202012 (with https://github.com/sonic-net/sonic-buildimage/pull/14927) to master - 202205 (with this change cherry-picked) to master --- .../build_templates/sonic_debian_extension.j2 | 3 +- platform/mellanox/mlnx-ffb.sh | 72 ++++++++++--------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 5181e412c819..04a404688ff3 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -923,7 +923,8 @@ for fw_file_name in ${!FW_FILE_MAP[@]}; do # Link old FW location to not break existing automation/scripts sudo ln -s /host/image-$SONIC_IMAGE_VERSION/$PLATFORM_DIR/fw/asic/${FW_FILE_MAP[$fw_file_name]} $FILESYSTEM_ROOT/etc/mlnx/${FW_FILE_MAP[$fw_file_name]} done -sudo cp $files_path/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version +sudo cp $files_path/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/$PLATFORM_DIR/fw/asic/issu-version +sudo ln -s /host/image-$SONIC_IMAGE_VERSION/$PLATFORM_DIR/fw/asic/issu-version $FILESYSTEM_ROOT/etc/mlnx/issu-version sudo cp $files_path/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh sudo cp $files_path/$MLNX_ONIE_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_ONIE_FW_UPDATE sudo cp $files_path/$MLNX_SSD_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_SSD_FW_UPDATE diff --git a/platform/mellanox/mlnx-ffb.sh b/platform/mellanox/mlnx-ffb.sh index afe42c819870..75faeb514c63 100755 --- a/platform/mellanox/mlnx-ffb.sh +++ b/platform/mellanox/mlnx-ffb.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. # Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,41 +49,47 @@ check_sdk_upgrade() return "${FFB_SUCCESS}" fi - while :; do - mkdir -p "${FS_MOUNTPOINT}" - mount -t squashfs "${FS_PATH}" "${FS_MOUNTPOINT}" || { - >&2 echo "Failed to mount next SONiC image" + ISSU_VERSION_FILE_PATH="/etc/mlnx/issu-version" + CURRENT_ISSU_VERSION="$(cat ${ISSU_VERSION_FILE_PATH})" + NEXT_ISSU_VERSION="Unknown" + + # /host/image-/platform/fw/asic/issu-version is now the new location for ISSU version. + NEXT_IMAGE_ISSU_VERSION_FILE_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}/platform/fw/asic/issu-version" + + if [ -f "${NEXT_IMAGE_ISSU_VERSION_FILE_PATH}" ]; then + NEXT_ISSU_VERSION="$(cat ${NEXT_IMAGE_ISSU_VERSION_FILE_PATH})" + else + while :; do + mkdir -p "${FS_MOUNTPOINT}" + mount -t squashfs "${FS_PATH}" "${FS_MOUNTPOINT}" || { + >&2 echo "Failed to mount next SONiC image" + break + } + + [ -f "${ISSU_VERSION_FILE_PATH}" ] || { + >&2 echo "No ISSU version file found ${ISSU_VERSION_FILE_PATH}" + break + } + + [ -f "${FS_MOUNTPOINT}/${ISSU_VERSION_FILE_PATH}" ] || { + >&2 echo "No ISSU version file found ${ISSU_VERSION_FILE_PATH} in ${NEXT_SONIC_IMAGE}" + break + } + NEXT_ISSU_VERSION="$(cat ${FS_MOUNTPOINT}/${ISSU_VERSION_FILE_PATH})" break - } + done - ISSU_VERSION_FILE_PATH="/etc/mlnx/issu-version" - - [ -f "${ISSU_VERSION_FILE_PATH}" ] || { - >&2 echo "No ISSU version file found ${ISSU_VERSION_FILE_PATH}" - break - } - - [ -f "${FS_MOUNTPOINT}/${ISSU_VERSION_FILE_PATH}" ] || { - >&2 echo "No ISSU version file found ${ISSU_VERSION_FILE_PATH} in ${NEXT_SONIC_IMAGE}" - break - } - - CURRENT_ISSU_VERSION="$(cat ${ISSU_VERSION_FILE_PATH})" - NEXT_ISSU_VERSION="$(cat ${FS_MOUNTPOINT}/${ISSU_VERSION_FILE_PATH})" - - if [[ "${CURRENT_ISSU_VERSION}" == "${NEXT_ISSU_VERSION}" ]]; then - CHECK_RESULT="${FFB_SUCCESS}" - else - >&2 echo "Current and next ISSU version do not match:" - >&2 echo "Current ISSU version: ${CURRENT_ISSU_VERSION}" - >&2 echo "Next ISSU version: ${NEXT_ISSU_VERSION}" - fi - - break - done + umount -rf "${FS_MOUNTPOINT}" 2> /dev/null || true + rm -rf "${FS_MOUNTPOINT}" 2> /dev/null || true + fi - umount -rf "${FS_MOUNTPOINT}" 2> /dev/null || true - rm -rf "${FS_MOUNTPOINT}" 2> /dev/null || true + if [[ "${CURRENT_ISSU_VERSION}" == "${NEXT_ISSU_VERSION}" ]]; then + CHECK_RESULT="${FFB_SUCCESS}" + else + >&2 echo "Current and next ISSU version do not match:" + >&2 echo "Current ISSU version: ${CURRENT_ISSU_VERSION}" + >&2 echo "Next ISSU version: ${NEXT_ISSU_VERSION}" + fi return "${CHECK_RESULT}" }