[mellanox|ffb] ISSU version check (#2437)
* Revert "[mellanox]: Integrate CRIU tool to SYNCD docker container (#2061)"
This reverts commit 514b38f348
.
Conflicts:
platform/mellanox/docker-syncd-mlnx.mk
sonic-slave/Dockerfile
* [mellanox|ffb] remove unused scripts
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
* [mellanox|ffb] ISSU version check
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
* [mlnx|ffb] remove extra ';'
Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
This commit is contained in:
parent
81467ae74a
commit
0921211009
@ -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 %}
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
CRIU_VERSION = 3.10
|
||||
|
||||
export CRIU_VERSION
|
||||
|
||||
CRIU = criu_$(CRIU_VERSION)-1_amd64.deb
|
||||
$(CRIU)_SRC_PATH = $(PLATFORM_PATH)/criu
|
||||
$(CRIU)_DEPENDS += $(LIBNL3_DEV)
|
||||
SONIC_MAKE_DEBS += $(CRIU)
|
@ -1,14 +0,0 @@
|
||||
.ONESHELL:
|
||||
SHELL = /bin/bash
|
||||
.SHELLFLAGS += -e
|
||||
|
||||
MAIN_TARGET = criu_$(CRIU_VERSION)-1_amd64.deb
|
||||
|
||||
CRIU_DEPS = iptables,protobuf-c-compiler,protobuf-compiler,python-protobuf,libprotobuf-c1,python-future,python-ipaddr,libnet1,pkg-config,asciidoc,xmlto
|
||||
|
||||
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
|
||||
rm -rf criu
|
||||
git clone -b v$(CRIU_VERSION) https://github.com/checkpoint-restore/criu.git
|
||||
pushd criu
|
||||
RUNDIR=/run/criu make
|
||||
sudo checkinstall --default --install=no --fstrans=no --pkgversion=$(CRIU_VERSION) --maintainer='@' --requires=$(CRIU_DEPS) --pakdir=$(DEST)
|
@ -2,7 +2,7 @@
|
||||
|
||||
DOCKER_SYNCD_MLNX_RPC = docker-syncd-mlnx-rpc.gz
|
||||
$(DOCKER_SYNCD_MLNX_RPC)_PATH = $(PLATFORM_PATH)/docker-syncd-mlnx-rpc
|
||||
$(DOCKER_SYNCD_MLNX_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT) $(MLNX_SFPD) $(MLNX_ISSU)
|
||||
$(DOCKER_SYNCD_MLNX_RPC)_DEPENDS += $(SYNCD_RPC) $(LIBTHRIFT) $(MLNX_SFPD)
|
||||
$(DOCKER_SYNCD_MLNX_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_MLNX)
|
||||
SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_MLNX_RPC)
|
||||
ifeq ($(ENABLE_SYNCD_RPC),y)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
DOCKER_SYNCD_MLNX = docker-syncd-mlnx.gz
|
||||
$(DOCKER_SYNCD_MLNX)_PATH = $(PLATFORM_PATH)/docker-syncd-mlnx
|
||||
$(DOCKER_SYNCD_MLNX)_DEPENDS += $(SYNCD) $(PYTHON_SDK_API) $(MLNX_SFPD) $(CRIU) $(MLNX_ISSU)
|
||||
$(DOCKER_SYNCD_MLNX)_DEPENDS += $(SYNCD) $(PYTHON_SDK_API) $(MLNX_SFPD)
|
||||
$(DOCKER_SYNCD_MLNX)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE)
|
||||
SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_MLNX)
|
||||
ifneq ($(ENABLE_SYNCD_RPC),y)
|
||||
@ -14,4 +14,4 @@ $(DOCKER_SYNCD_MLNX)_RUN_OPT += --net=host --privileged -t
|
||||
$(DOCKER_SYNCD_MLNX)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf
|
||||
$(DOCKER_SYNCD_MLNX)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
|
||||
$(DOCKER_SYNCD_MLNX)_RUN_OPT += -v /host/warmboot:/var/warmboot
|
||||
$(DOCKER_SYNCD_MLNX)_RUN_OPT += --tmpfs /run/criu
|
||||
|
||||
|
@ -14,7 +14,7 @@ debs/{{ deb }}{{' '}}
|
||||
{%- endfor -%}
|
||||
debs/
|
||||
|
||||
RUN apt-get install -y --no-install-recommends libxml2 iptables libbsd0 protobuf-c-compiler protobuf-compiler python-protobuf libprotobuf-c1 python-future python-ipaddr libnet1 pkg-config asciidoc xmlto
|
||||
RUN apt-get install -y libxml2
|
||||
|
||||
RUN dpkg -i \
|
||||
{% for deb in docker_syncd_mlnx_debs.split(' ') -%}
|
||||
|
9
platform/mellanox/issu-version.mk
Normal file
9
platform/mellanox/issu-version.mk
Normal file
@ -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
|
||||
|
12
platform/mellanox/issu-version/Makefile
Normal file
12
platform/mellanox/issu-version/Makefile
Normal file
@ -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
|
||||
}
|
@ -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}"
|
||||
break;
|
||||
[ -f "${SDK_VERSION_FILE_PATH}" ] || {
|
||||
>&2 echo "No ISSU version file found ${ISSU_VERSION_FILE_PATH}"
|
||||
break
|
||||
}
|
||||
|
||||
ISSU_CHECK_CMD="docker exec -t syncd issu --check ${NEXT_SDK_VERSION}"
|
||||
CURRENT_ISSU_VERSION="$(cat ${ISSU_VERSION_FILE_PATH})"
|
||||
NEXT_ISSU_VERSION="$(cat ${FS_MOUNTPOINT}/${ISSU_VERSION_FILE_PATH})"
|
||||
|
||||
${ISS_CHECK_CMD} > /dev/null && CHECK_RESULT="${FFB_SUCCESS}"
|
||||
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,34 +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}";
|
||||
|
||||
return "${FFB_SUCCESS}"
|
||||
}
|
||||
|
||||
# Perform ISSU start
|
||||
issu_start()
|
||||
{
|
||||
ISSU_START_CMD="docker exec -t syncd issu --start"
|
||||
${ISSU_START_CMD} > /dev/null
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
return $EXIT_CODE
|
||||
}
|
||||
|
||||
# Perform ISSU end
|
||||
issu_end()
|
||||
{
|
||||
ISSU_END_CMD="docker exec -t syncd issu --end"
|
||||
${ISSU_END_CMD} > /dev/null
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
return $EXIT_CODE
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
# issu (SONiC MLNX platform ISSU tool) Debian package
|
||||
|
||||
MLNX_ISSU = python-mlnx-issu_1.0-1_all.deb
|
||||
$(MLNX_ISSU)_SRC_PATH = $(PLATFORM_PATH)/mlnx-issu
|
||||
SONIC_PYTHON_STDEB_DEBS += $(MLNX_ISSU)
|
@ -1,176 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
'''
|
||||
This code is for a mlnx platform specific tool, issu.
|
||||
This tool provides an CLI interface to interact with SDK ISSU module
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import errno
|
||||
import syslog
|
||||
import argparse
|
||||
|
||||
from functools import wraps
|
||||
|
||||
from python_sdk_api import sx_api
|
||||
|
||||
# ========================== Constants ===============================
|
||||
SDK_VERSION_PATTERN = r'(\d+)\.(\d+)\.(.*)'
|
||||
SYSLOG_IDENTIFIER = "ISSU"
|
||||
|
||||
|
||||
# Flag that indicates whether to print logs to stdout
|
||||
verbose = False
|
||||
|
||||
|
||||
# ========================== Syslog wrappers ==========================
|
||||
def log_info(msg):
|
||||
syslog.openlog(SYSLOG_IDENTIFIER)
|
||||
syslog.syslog(syslog.LOG_INFO, msg)
|
||||
syslog.closelog()
|
||||
|
||||
if verbose:
|
||||
print(msg)
|
||||
|
||||
def log_warning(msg):
|
||||
syslog.openlog(SYSLOG_IDENTIFIER)
|
||||
syslog.syslog(syslog.LOG_WARNING, msg)
|
||||
syslog.closelog()
|
||||
|
||||
if verbose:
|
||||
print(msg)
|
||||
|
||||
def log_error(msg):
|
||||
syslog.openlog(SYSLOG_IDENTIFIER)
|
||||
syslog.syslog(syslog.LOG_ERR, msg)
|
||||
syslog.closelog()
|
||||
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
|
||||
# ========================== Global functions =========================
|
||||
def with_sdk_handle(func):
|
||||
""" A decorator for @func that use sx api
|
||||
that gets a SDK handler, calls func(handler, *args, **kwargs)
|
||||
and then closes the handler regardless of func failure"""
|
||||
|
||||
@wraps(func)
|
||||
def wrapped(*args, **kwargs):
|
||||
log_info("opening sdk")
|
||||
rc, handle = sx_api.sx_api_open(None)
|
||||
log_info("sx_api_open handle: 0x%x , rc %d " % ( handle, rc) )
|
||||
|
||||
if rc != sx_api.SX_STATUS_SUCCESS:
|
||||
log_error("failed to open api handle. Please check that SDK is running")
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
try:
|
||||
res = func(handle, *args, **kwargs)
|
||||
finally:
|
||||
log_info("closing sdk handle")
|
||||
rc = sx_api.sx_api_close(handle)
|
||||
|
||||
if rc != sx_api.SX_STATUS_SUCCESS:
|
||||
log_error("failed to close api handle")
|
||||
|
||||
return res
|
||||
|
||||
return wrapped
|
||||
|
||||
|
||||
def check_sdk_version_pattern(sdk_version):
|
||||
"""Checker for @sdk_version"""
|
||||
|
||||
if not re.match(SDK_VERSION_PATTERN, sdk_version):
|
||||
raise argparse.ArgumentTypeError("{} is an invalid SDK version string".format(sdk_version))
|
||||
|
||||
return sdk_version
|
||||
|
||||
|
||||
@with_sdk_handle
|
||||
def check_issu_upgrade_to_sdk_version(handle, new_sdk):
|
||||
"""This function checks whether ISSU upgrade to @new_sdk version is posible"""
|
||||
|
||||
version = sx_api.new_sx_api_sx_sdk_versions_t_p()
|
||||
rc = sx_api.sx_api_sx_sdk_version_get(handle, version)
|
||||
|
||||
if rc != sx_api.SX_STATUS_SUCCESS:
|
||||
log_error("failed to get current SDK version")
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
current_sdk = version.sx_sdk
|
||||
|
||||
succeed = True
|
||||
|
||||
log_info('check ISSU upgrade: current SDK: {}, new SDK: {}, check succeed: {}'.format(current_sdk, new_sdk, succeed))
|
||||
|
||||
return succeed
|
||||
|
||||
|
||||
@with_sdk_handle
|
||||
def issu_start(handle):
|
||||
"""This function calls ISSU start API"""
|
||||
|
||||
log_info("call ISSU start")
|
||||
rc = sx_api.sx_api_issu_start_set(handle)
|
||||
|
||||
if rc != sx_api.SX_STATUS_SUCCESS:
|
||||
log_error("failed to execute ISSU start API")
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
@with_sdk_handle
|
||||
def issu_end(handle):
|
||||
"""This function calls ISSU end API"""
|
||||
|
||||
log_info("call ISSU end")
|
||||
rc = sx_api.sx_api_issu_end_set(handle)
|
||||
|
||||
if rc != sx_api.SX_STATUS_SUCCESS:
|
||||
log_error("failed to execute ISSU end API")
|
||||
sys.exit(errno.EACCES)
|
||||
|
||||
|
||||
def get_parser():
|
||||
"""This function creates an argument parser"""
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-c', '--check', nargs=1, action='store', default=None, type=check_sdk_version_pattern,
|
||||
help='Check if ISSU upgrade is supported to new SDK version')
|
||||
parser.add_argument('-s', '--start', action='store_true', help='Call ISSU start API')
|
||||
parser.add_argument('-e', '--end', action='store_true', help='Call ISSU end API')
|
||||
parser.add_argument('-v', '--verbose', action='store_true', default=False)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
global verbose
|
||||
|
||||
parser = get_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
verbose = args.verbose
|
||||
|
||||
if args.check is not None:
|
||||
new_sdk = args.check[0]
|
||||
is_supported = check_issu_upgrade_to_sdk_version(new_sdk)
|
||||
|
||||
if verbose:
|
||||
print('SDK upgrade is{}supported'.format(' ' if is_supported else ' not '))
|
||||
|
||||
if not is_supported:
|
||||
sys.exit(1)
|
||||
elif args.start:
|
||||
issu_start()
|
||||
elif args.end:
|
||||
issu_end()
|
||||
else:
|
||||
parser.parse_args(['-h'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,14 +0,0 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='mlnx-issu',
|
||||
version='1.0',
|
||||
description='MLNX ISSU tool for SONiC on mellanox platform',
|
||||
author='SONiC Community',
|
||||
url='https://github.com/Azure/sonic-buildimage/',
|
||||
maintainer='Stepan Blyschak',
|
||||
maintainer_email='stepanb@mellanox.com',
|
||||
scripts=[
|
||||
'scripts/issu',
|
||||
]
|
||||
)
|
@ -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)
|
||||
|
@ -12,7 +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)/mlnx-issu.mk
|
||||
include $(PLATFORM_PATH)/issu-version.mk
|
||||
|
||||
SONIC_ALL += $(SONIC_ONE_IMAGE) \
|
||||
$(DOCKER_FPM)
|
||||
|
@ -1 +0,0 @@
|
||||
{{ MLNX_SDK_VERSION }}
|
@ -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
|
||||
|
@ -232,19 +232,6 @@ RUN apt-get update && apt-get install -y \
|
||||
texi2html \
|
||||
# For initramfs
|
||||
bash-completion \
|
||||
# For Mellanox CRIU build
|
||||
libprotobuf-dev \
|
||||
libprotobuf-c0-dev \
|
||||
protobuf-c-compiler \
|
||||
protobuf-compiler \
|
||||
python-protobuf \
|
||||
pkg-config \
|
||||
libnet1-dev \
|
||||
libnet-dev \
|
||||
libaio-dev \
|
||||
asciidoc \
|
||||
xmlto \
|
||||
checkinstall \
|
||||
# For sonic vs image build
|
||||
dosfstools \
|
||||
qemu-kvm \
|
||||
|
Loading…
Reference in New Issue
Block a user