Convert boot_failure to counter and add system_mode
This commit converts the boot_failure variable to be a counter
instead of a boolean variable, adds a logic to set the default
grub menu entry as the other available in case of three
consecutive boot failures, and adds the system_mode variable,
that will be assigned with the actual system_mode value by the
change in [1].
Note: The 'Depends-On' commit adds a service to reset the
boot_failure counter value to 0 once the system boots
successfully
[1] https://review.opendev.org/c/starlingx/stx-puppet/+/952869
Test Plan
PASS: simulate a boot failure (e.g. reset the host while
it is being booted) and verify the counter increments
PASS: simulate a boot failure until the counter reaches the
maximum retry value, then verify grub sets the default
entry as the rollback
PASS: integrated test for automatic boot recovery (AIO-SX)
1. upgrade host from stx-10 to stx-11 with LVM snapshot
feature enabled
2. force failure during the boot sequence (3x)
3. system boots in the rollback deployment
4. LVM snapshots are restored during the boot sequence
and system is rebooted again
5. system boots in from-release ready to 'deploy delete'
Story: 2011357
Task: 52402
Depends-On: https://review.opendev.org/c/starlingx/update/+/952865
Change-Id: I2a03acf2b589373d4eaab08a71db6a58c2672200
Signed-off-by: Heitor Matsui <heitorvieira.matsui@windriver.com>
This commit is contained in:
@@ -14,6 +14,7 @@ set kernel_rollback=vmlinuz
|
||||
set kernel_params=""
|
||||
set kernel_params_ext=""
|
||||
set boot_failure="0"
|
||||
set system_mode="simplex"
|
||||
|
||||
if [ "${legacy_bios}" != "1" ]; then
|
||||
set boot_env_path=${prefix}
|
||||
@@ -21,12 +22,22 @@ fi
|
||||
|
||||
if [ -e ${boot_env_path}/boot.env ]; then
|
||||
load_env -s -f ${boot_env_path}/boot.env
|
||||
if [ "$boot_failure" = "1" ]; then
|
||||
set default="1"
|
||||
else
|
||||
set default="0"
|
||||
if [ "$boot_failure" = "0" ]; then
|
||||
set boot_failure="1"
|
||||
elif [ "$boot_failure" = "1" ]; then
|
||||
set boot_failure="2"
|
||||
elif [ "$boot_failure" = "2" ]; then
|
||||
set boot_failure="3"
|
||||
elif [ "$boot_failure" = "3" ]; then
|
||||
set boot_failure="0"
|
||||
if [ $default = "0" ]; then
|
||||
set default="1"
|
||||
else
|
||||
set default="0"
|
||||
fi
|
||||
save_env -f ${boot_env_path}/boot.env default
|
||||
fi
|
||||
save_env -f ${boot_env_path}/boot.env default
|
||||
save_env -f ${boot_env_path}/boot.env boot_failure
|
||||
fi
|
||||
|
||||
set partition_based_root="0"
|
||||
@@ -159,16 +170,18 @@ else
|
||||
initrd /1/initramfs
|
||||
}
|
||||
|
||||
menuentry "StarlingX ostree${boot_mode} ${kernel_rollback} (Rollback)" --unrestricted {
|
||||
if [ "${legacy_bios}" != "1" ]; then
|
||||
efi-watchdog enable 0 180
|
||||
fi
|
||||
search --no-floppy --label --set=root ${boot_part}${boot_mode}
|
||||
if [ -e /2/kernel.env ] ; then
|
||||
load_env -s -f /2/kernel.env kernel_params_ext
|
||||
fi
|
||||
linux /2/${kernel_rollback} rw rootwait ostree_boot=LABEL=${boot_part}${boot_mode} ostree_root=${ostree_root_lv} rd.lvm.lv=${kernel_root_lv} ostree_var=${ostree_var_lv} ostree=/ostree/2 $ostree_console $kernel_params $kernel_params_ext
|
||||
initrd /2/initramfs
|
||||
}
|
||||
if [ "${system_mode}" = "simplex" ]; then
|
||||
menuentry "StarlingX ostree${boot_mode} ${kernel_rollback} (Rollback)" --unrestricted {
|
||||
if [ "${legacy_bios}" != "1" ]; then
|
||||
efi-watchdog enable 0 180
|
||||
fi
|
||||
search --no-floppy --label --set=root ${boot_part}${boot_mode}
|
||||
if [ -e /2/kernel.env ] ; then
|
||||
load_env -s -f /2/kernel.env kernel_params_ext
|
||||
fi
|
||||
linux /2/${kernel_rollback} rw rootwait ostree_boot=LABEL=${boot_part}${boot_mode} ostree_root=${ostree_root_lv} rd.lvm.lv=${kernel_root_lv} ostree_var=${ostree_var_lv} ostree=/ostree/2 $ostree_console $kernel_params $kernel_params_ext
|
||||
initrd /2/initramfs
|
||||
}
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user