From d7ff642a389e47a4f38fa7c2fabbe71fbbb05f21 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Fri, 18 Apr 2025 19:59:55 +0200 Subject: T1771: automatic reboot of system into previous image If any part of the system boot fails, we set overall_status=1 in the vyos-router startup script. When an error during the image upgrade is detected, the system will automatically revert the default boot image to the previously used version, if the CLI option "system option reboot-on-upgrade-failure" is set. The user is informed via console messages: Booting failed, reverting to previous image Automatic reboot in 5 minutes Use "reboot cancel" to cancel The user has time to log in and run reboot cancel to remain in the faulty image for troubleshooting. Reboot timeout is defined by CLI: "system option reboot-on-upgrade-failure" Once the system boots into the previous image, the MOTD will display a persistent warning message - cleared during next reboot. WARNING: Image update to "VyOS 1.5.xxxx" failed Please check the logs: /usr/lib/live/mount/persistence/boot/NAME/rw/var/log Message is cleared on next reboot! Upgrade failure can be synthetically injected by booting with Kernel command line option: vyos-fail-migration --- src/helpers/run-config-migration.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/helpers/run-config-migration.py') diff --git a/src/helpers/run-config-migration.py b/src/helpers/run-config-migration.py index e6ce97363..8e0d56150 100755 --- a/src/helpers/run-config-migration.py +++ b/src/helpers/run-config-migration.py @@ -19,6 +19,7 @@ import sys import time from argparse import ArgumentParser from shutil import copyfile +from vyos.utils.file import read_file from vyos.migrate import ConfigMigrate from vyos.migrate import ConfigMigrateError @@ -76,3 +77,9 @@ except ConfigMigrateError as e: if backup is not None and not config_migrate.config_modified: os.unlink(backup) + +# T1771: add knob on Kernel command-line to simulate failed config migrator run +# used to test if the automatic image reboot works. +kernel_cmdline = read_file('/proc/cmdline') +if 'vyos-fail-migration' in kernel_cmdline.split(): + sys.exit(1) -- cgit v1.2.3