From e8d7dcd56761ae4db2e64f037ecea681d0a6d7cc Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Fri, 11 Jan 2019 11:52:57 +0000 Subject: [PATCH] [mellanox|ffb] ISSU version check Signed-off-by: Stepan Blyschak --- .../build_templates/sonic_debian_extension.j2 | 2 +- platform/mellanox/issu-version.mk | 9 ++++++ platform/mellanox/issu-version/Makefile | 12 ++++++++ platform/mellanox/mlnx-ffb.sh | 28 +++++++++++-------- platform/mellanox/one-image.mk | 2 +- platform/mellanox/rules.mk | 1 + platform/mellanox/sdk-version.j2 | 1 - platform/mellanox/sdk.mk | 1 - 8 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 platform/mellanox/issu-version.mk create mode 100644 platform/mellanox/issu-version/Makefile delete mode 100755 platform/mellanox/sdk-version.j2 diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index ed8df864cd06..4ef014a30e4b 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -319,9 +319,9 @@ sudo cp {{src}} $FILESYSTEM_ROOT/{{dst}} {% if sonic_asic_platform == "mellanox" %} sudo mkdir -p $FILESYSTEM_ROOT/etc/mlnx/ sudo cp target/files/$MLNX_FW_FILE $FILESYSTEM_ROOT/etc/mlnx/fw-SPC.mfa +sudo cp target/files/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version sudo cp target/files/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh -j2 platform/mellanox/sdk-version.j2 | sudo tee $FILESYSTEM_ROOT/etc/mlnx/sdk-version sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh {% endif %} diff --git a/platform/mellanox/issu-version.mk b/platform/mellanox/issu-version.mk new file mode 100644 index 000000000000..c7ae4296ab7a --- /dev/null +++ b/platform/mellanox/issu-version.mk @@ -0,0 +1,9 @@ +# ISSU version + +ISSU_VERSION_FILE = issu-version +$(ISSU_VERSION_FILE)_SRC_PATH = $(PLATFORM_PATH)/issu-version +$(ISSU_VERSION_FILE)_DEPENDS += $(APPLIBS) +SONIC_MAKE_FILES += $(ISSU_VERSION_FILE) + +export ISSU_VERSION_FILE + diff --git a/platform/mellanox/issu-version/Makefile b/platform/mellanox/issu-version/Makefile new file mode 100644 index 000000000000..1f7d7fba3a3f --- /dev/null +++ b/platform/mellanox/issu-version/Makefile @@ -0,0 +1,12 @@ +.ONESHELL: +SHELL = /bin/bash +.SHELLFLAGS += -e + +MAIN_TARGET = issu-version + +$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : + sx_sdk --version | egrep -o 'ISSU [0-9]+' > $(DEST)/$(MAIN_TARGET) || { + echo "ISSU version is undefined: $(sx_sdk --version)" + rm $(DEST)/$(MAIN_TARGET) + exit 1 + } diff --git a/platform/mellanox/mlnx-ffb.sh b/platform/mellanox/mlnx-ffb.sh index e3eb87714a7a..2ae31175b8c0 100755 --- a/platform/mellanox/mlnx-ffb.sh +++ b/platform/mellanox/mlnx-ffb.sh @@ -37,21 +37,26 @@ check_sdk_upgrade() mkdir -p "${FS_MOUNTPOINT}" mount -t squashfs "${FS_PATH}" "${FS_MOUNTPOINT}" || { >&2 echo "Failed to mount next SONiC image" - break; + break } - SDK_VERSION_FILE_PATH="${FS_MOUNTPOINT}/etc/mlnx/sdk-version" + ISSU_VERSION_FILE_PATH="/etc/mlnx/issu-version" - [ -f "${SDK_VERSION_FILE_PATH}" ] && { - NEXT_SDK_VERSION="$(cat ${FS_MOUNTPOINT}/etc/mlnx/sdk-version)" - } || { - >&2 echo "No SDK version file ${SDK_VERSION_FILE_PATH}" + [ -f "${SDK_VERSION_FILE_PATH}" ] || { + >&2 echo "No ISSU version file found ${ISSU_VERSION_FILE_PATH}" break; } - # TODO: Place a call to SDK check script - # for now assume check succeeded - CHECK_RESULT="${FFB_SUCCESS}" + 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 @@ -65,14 +70,15 @@ check_sdk_upgrade() check_ffb() { check_issu_enabled || { - echo "ISSU is not enabled on this HWSKU" + >&2 echo "ISSU is not enabled on this HWSKU" return "${FFB_FAILURE}" } check_sdk_upgrade || { - echo "SDK upgrade check failued" + >&2 echo "SDK upgrade check failued" return "${FFB_FAILURE}" } + return "${FFB_SUCCESS}"; } diff --git a/platform/mellanox/one-image.mk b/platform/mellanox/one-image.mk index 3a99f1c66c80..6fd5af193276 100644 --- a/platform/mellanox/one-image.mk +++ b/platform/mellanox/one-image.mk @@ -5,5 +5,5 @@ $(SONIC_ONE_IMAGE)_MACHINE = mellanox $(SONIC_ONE_IMAGE)_IMAGE_TYPE = onie $(SONIC_ONE_IMAGE)_INSTALLS += $(SX_KERNEL) $(KERNEL_MFT) $(MFT_OEM) $(MFT) $(MLNX_HW_MANAGEMENT) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_IMAGES) -$(SONIC_ONE_IMAGE)_FILES += $(MLNX_FW_FILE) $(MLNX_FFB_SCRIPT) +$(SONIC_ONE_IMAGE)_FILES += $(MLNX_FW_FILE) $(MLNX_FFB_SCRIPT) $(ISSU_VERSION_FILE) SONIC_INSTALLERS += $(SONIC_ONE_IMAGE) diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index e1a598225737..1c0072bec3ce 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -12,6 +12,7 @@ include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/docker-ptf-mlnx.mk include $(PLATFORM_PATH)/mlnx-sfpd.mk include $(PLATFORM_PATH)/mlnx-ffb.mk +include $(PLATFORM_PATH)/issu-version.mk SONIC_ALL += $(SONIC_ONE_IMAGE) \ $(DOCKER_FPM) diff --git a/platform/mellanox/sdk-version.j2 b/platform/mellanox/sdk-version.j2 deleted file mode 100755 index 5bba188430d6..000000000000 --- a/platform/mellanox/sdk-version.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ MLNX_SDK_VERSION }} \ No newline at end of file diff --git a/platform/mellanox/sdk.mk b/platform/mellanox/sdk.mk index c7ca2a513072..ec21563cc450 100644 --- a/platform/mellanox/sdk.mk +++ b/platform/mellanox/sdk.mk @@ -56,4 +56,3 @@ $(eval $(foreach deb,$(PYTHON_SDK_API) $(SX_KERNEL) $(SX_KERNEL_DEV),$(call make SONIC_ONLINE_DEBS += $(MLNX_SDK_RDEBS) $(PYTHON_SDK_API) $(SX_KERNEL) -export MLNX_SDK_VERSION