summaryrefslogtreecommitdiff
path: root/src/helpers/run-config-migration.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-04-18 19:59:55 +0200
committerChristian Breunig <christian@breunig.cc>2025-05-17 16:05:38 +0200
commitd7ff642a389e47a4f38fa7c2fabbe71fbbb05f21 (patch)
tree50b9373e41bdaaa66d985a4f1d6df74f813b7b35 /src/helpers/run-config-migration.py
parent74d848a981e25a5a3f563e355ba658ce70acf626 (diff)
downloadvyos-1x-d7ff642a389e47a4f38fa7c2fabbe71fbbb05f21.tar.gz
vyos-1x-d7ff642a389e47a4f38fa7c2fabbe71fbbb05f21.zip
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
Diffstat (limited to 'src/helpers/run-config-migration.py')
-rwxr-xr-xsrc/helpers/run-config-migration.py7
1 files changed, 7 insertions, 0 deletions
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)