Skip to content

Commit

Permalink
Iterate over passive snapshots on boot-assessment
Browse files Browse the repository at this point in the history
This commit prevents falling back to recovery system during the boot
assessment process.

In addition it also sets the boot_assessment to be executed on install
and reset reboots.

Signed-off-by: David Cassany <[email protected]>
  • Loading branch information
davidcassany committed Mar 25, 2024
1 parent 1625514 commit 1d68bf8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Boot assessment works this way:
# - After upgrade we set the boot_assessment_check=yes variable, this way grub will
# - After upgrade, install or reset we set the boot_assessment_check=yes variable, this way grub will
# include `elemental.health_check` flag in kernel command line.
# - On reboot grub detects the `boot_assessment_check=yes` and sets `last_boot_attempt`
# to store the menu entry that is currently attempting to boot.
Expand Down Expand Up @@ -30,20 +30,19 @@ stages:
set extra_passive_cmdline="${extra_passive_cmdline} elemental.health_check"
if [ -z "${selected_entry}" ]; then
if [ -n "${last_boot_attempt}" ]; then
for entry in ${fallback}; do
if [ "${break}" == "yes" ]; then
set default="${entry}"
if [ -z "${last_boot_attempt}" ]; then
set default="active"
else
for entry in ${passive_snaps}; do
set default="passive${entry}"
if [ "${last_boot_attempt}" == "active" -o "${previous_done}" == "yes" ]; then
break
fi
if [ "${last_boot_attempt}" == "${entry}" ]; then
set break="yes"
if [ "${last_boot_attempt}" == "passive${entry}" ]; then
set previous_done="yes"
fi
done
fi
if [ -z "${default}" ]; then
set default="0"
fi
set last_boot_attempt="${default}"
save_env -f "(${oem_blk})${env_file}" last_boot_attempt
fi
Expand All @@ -57,18 +56,16 @@ stages:
echo "source /grubcustom/bootassessment.cfg" >> /run/elemental/efi/grubcustom/custom.cfg
fi
- &resetInstall
name: "Clear GRUB sentinels"
- &setCheck
name: "Set check required on upgrade or firstboot"
commands:
- grub2-editenv /oem/grubenv unset boot_assessment_check last_boot_attempt
- grub2-editenv /oem/grubenv set boot_assessment_check=yes
- grub2-editenv /oem/grubenv unset last_boot_attempt

after-upgrade-chroot:
- <<: *install
- name: "Set check required on upgrade"
commands:
- grub2-editenv /oem/grubenv set boot_assessment_check=yes
- grub2-editenv /oem/grubenv unset last_boot_attempt
- <<: *setCheck

after-reset-chroot:
- <<: *install
- <<: *resetInstall
- <<: *setCheck
2 changes: 1 addition & 1 deletion pkg/features/embedded/grub-config/etc/elemental/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fi
if [ "${default_fallback}" ]; then
set fallback="${default_fallback}"
else
set fallback="0 1"
set fallback="0 recovery"
fi

## Include custom file if any
Expand Down
2 changes: 1 addition & 1 deletion tests/assets/boot_checker_failure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ stages:
exit 1
permissions: 0755
owner: 0
group: 0
group: 0

0 comments on commit 1d68bf8

Please sign in to comment.