-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mellanox|FFB]: Add support for Mellanox fast-fast boot (#2294)
* [mlnx|ffb] Add support for mellanox fast-fast boot Signed-off-by: Stepan Blyschak <stepanb@mellanox.com> * [mlnx|ffb]: Add support of "config end" event for mlnx fast-fast boot Signed-off-by: Volodymyr Samotiy <volodymyrs@mellanox.com> * [Mellanox|FFB]: Fix review comments * Change naming convention from "fast-fast" to "fastfast" Signed-off-by: Volodymyr Samotiy <volodymyrs@mellanox.com>
- Loading branch information
Showing
16 changed files
with
394 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,7 @@ | ||
# mellanox fast fast boot script | ||
|
||
MLNX_FFB_SCRIPT = mlnx-ffb.sh | ||
$(MLNX_FFB_SCRIPT)_PATH = platform/mellanox/ | ||
SONIC_COPY_FILES += $(MLNX_FFB_SCRIPT) | ||
|
||
export MLNX_FFB_SCRIPT |
This file contains 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,87 @@ | ||
#!/bin/bash | ||
|
||
FFB_SUCCESS=0 | ||
FFB_FAILURE=1 | ||
|
||
# Check if ISSU is enabled on this device | ||
check_issu_enabled() | ||
{ | ||
CHECK_RESULT="${FFB_FAILURE}" | ||
ISSU_CHECK_CMD="show platform mlnx issu" | ||
|
||
# Check whether show ISSU status outputs ENABLED | ||
if [[ `$ISSU_CHECK_CMD` =~ "enabled" ]]; then | ||
# ISSU enabled, return success | ||
CHECK_RESULT="${FFB_SUCCESS}" | ||
fi | ||
|
||
return "${CHECK_RESULT}" | ||
} | ||
|
||
# Check if ISSU upgrade from current SDK to next image SDK is supported | ||
check_sdk_upgrade() | ||
{ | ||
CHECK_RESULT="${FFB_FAILURE}" | ||
|
||
NEXT_SONIC_IMAGE="$(sonic_installer list | grep "Next: " | cut -f2 -d' ')" | ||
CURRENT_SONIC_IMAGE="$(sonic_installer list | grep "Current: " | cut -f2 -d' ')" | ||
|
||
FS_PATH="/host/image-${NEXT_SONIC_IMAGE#SONiC-OS-}/fs.squashfs" | ||
FS_MOUNTPOINT="/tmp/image-${NEXT_SONIC_IMAGE#SONiC-OS-}-fs" | ||
|
||
if [[ "${CURRENT_SONIC_IMAGE}" == "${NEXT_SONIC_IMAGE}" ]]; then | ||
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" | ||
break; | ||
} | ||
|
||
SDK_VERSION_FILE_PATH="${FS_MOUNTPOINT}/etc/mlnx/sdk-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; | ||
} | ||
|
||
ISSU_CHECK_CMD="docker exec -t syncd issu --check ${NEXT_SDK_VERSION}" | ||
|
||
${ISS_CHECK_CMD} > /dev/null && CHECK_RESULT="${FFB_SUCCESS}" | ||
|
||
break | ||
done | ||
|
||
umount -rf "${FS_MOUNTPOINT}" 2> /dev/null || true | ||
rm -rf "${FS_MOUNTPOINT}" 2> /dev/null || true | ||
|
||
return "${CHECK_RESULT}" | ||
} | ||
|
||
# Perform ISSU start | ||
issu_start() | ||
{ | ||
ISSU_START_CMD="docker exec -t syncd issu --start" | ||
${ISSU_START_CMD} > /dev/null | ||
|
||
EXIT_CODE=$? | ||
|
||
touch /host/warmboot/issu_started | ||
|
||
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 | ||
} |
This file contains 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,5 @@ | ||
# 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) |
This file contains 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,69 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Part of Mellanox platform specific fastfast boot implementation for warm-boot. | ||
Notifies SYNCD proccess once boot is finished after warm-reboot. | ||
Once SYNCD received such notification it should set appropriate SAI attribute. | ||
Then SAI will notify SDK to end ISSU mode for the FFB. | ||
""" | ||
|
||
|
||
import time | ||
import swsssdk | ||
from threading import Timer | ||
|
||
|
||
class FFB(object): | ||
"""Provides implementation for Mellanox fastfast boot""" | ||
DB_WARM_TABLE_KEY = 'WARM_RESTART_TABLE|bgp' | ||
DB_STATE_ENTRY_NAME = 'state' | ||
DB_STATE_TYPE_RECONCILED = 'reconciled' | ||
DB_CHANNEL_NAME = 'MLNX_FFB' | ||
DB_CHANNEL_MSG = '["SET","ISSU_END"]' # message should be in the following format: ["<operation>","<data>"] | ||
SUB_THREAD_TIMEOUT = 1 | ||
STOP_TIMER_TIMEOUT = 180 | ||
|
||
def __init__(self): | ||
self.state_db = swsssdk.SonicV2Connector() | ||
self.state_db.connect(self.state_db.STATE_DB) | ||
|
||
self.prevState = self.state_db.get(self.state_db.STATE_DB, self.DB_WARM_TABLE_KEY, self.DB_STATE_ENTRY_NAME) | ||
|
||
self.pubSub = self.state_db.redis_clients[self.state_db.STATE_DB].pubsub() | ||
self.pubSub.psubscribe(**{'__key*@6__:{}'.format(self.DB_WARM_TABLE_KEY): self.eventHandler}) | ||
|
||
self.timeoutTimer = Timer(self.STOP_TIMER_TIMEOUT, self.finish) | ||
|
||
def run(self): | ||
# Start event thread in order to get required events | ||
self.eventThread = self.pubSub.run_in_thread(sleep_time=self.SUB_THREAD_TIMEOUT) | ||
# Start oneshot timer in order to exit in case required event is not received during defined timeout | ||
self.timeoutTimer.start() | ||
|
||
def finish(self): | ||
# Stop event thread and timeout timer | ||
self.eventThread.stop() | ||
self.timeoutTimer.cancel() | ||
|
||
# Publish "FFB END" event to SYNCD process | ||
time.sleep(60) # W/A: Wait until configuration is applied to HW since it takes some time | ||
self.state_db.publish(self.state_db.STATE_DB, self.DB_CHANNEL_NAME, self.DB_CHANNEL_MSG) | ||
|
||
def eventHandler(self, msg): | ||
# Only "set" operations are needed so just skip all others | ||
if msg['data'] != 'hset': | ||
return | ||
|
||
state = self.state_db.get(self.state_db.STATE_DB, self.DB_WARM_TABLE_KEY, self.DB_STATE_ENTRY_NAME) | ||
|
||
if (state != self.prevState) and (state == self.DB_STATE_TYPE_RECONCILED): | ||
self.finish() | ||
else: | ||
self.prevState = state | ||
|
||
|
||
def main(): | ||
FFB().run() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.