Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterate over passive snapshots on boot-assessment #2027

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading