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

Make use of grub2 environment block #387

Merged
merged 2 commits into from
Jul 8, 2021
Merged

Conversation

davidcassany
Copy link
Contributor

This commit sets the grub2 configuration to load /grubenv file, if any,
and checks the next_entry variable to set the default grub2 option.

This is helpful to set default boot in grub only for the next boot. From
cOS it is enough to run grub2-editenv /oem/grubenv set next_entry=recovery to set the next reboot to default to recovery system.

Signed-off-by: David Cassany [email protected]

@davidcassany
Copy link
Contributor Author

@Itxaka @mudler I could not resist and did a PoC that worked out of the box, so here is the PR :)

With this grub config change we can run grub2-editenv /oem/grubenv set next_entry=recovery and the follow up boot it will default to recovery, but it will default to recovery only once, then it will be unset again. If you'd like to change the empty default to something else you could do grub2-editenv /oem/grubenv set default=fallback and then the default would be set to fallback permanently (obviously only as long as the /oem/grubenv file exists and it is configured as such).

I did not add a tests neither refactored any test since it collides with #382 and I did not want to conflict with it. But it should be pretty straight forward to use that on tests. Also probably a new test for that is not needed since it might be already tested on upgrade or recovery tests.

This PR might also be helpful to define a default reboot behavior in case we detect some obvious error at boot (we are dropped into an emergency shell, no login user is defined, etc.)

@davidcassany davidcassany marked this pull request as draft July 7, 2021 12:46
Copy link
Contributor

@mudler mudler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Looks good here and seems shouldn't even have side effects on old installs

@davidcassany
Copy link
Contributor Author

Nice! Looks good here and seems shouldn't even have side effects on old installs

Correct, that's my understanding too.

@mudler
Copy link
Contributor

mudler commented Jul 7, 2021

Maybe also worth it to add to the docs as well? Easy to forget in PRs, but I see this quite handy in the long run also when debugging things going bad from recovery

@Itxaka
Copy link
Contributor

Itxaka commented Jul 7, 2021

This is awesome!

@davidcassany davidcassany force-pushed the use_grub_environment_block branch 2 times, most recently from a8fb717 to 407149f Compare July 7, 2021 21:01
@davidcassany davidcassany marked this pull request as ready for review July 7, 2021 21:04
This commit sets the grub2 configuration to load /grubenv file, if any,
and checks the `next_entry` variable to set the default grub2 option.

This is helpful to set default boot in grub only for the next boot. From
cOS it is enough to run `grub2-editenv /oem/grubenv set
next_entry=recovery` to set the next reboot to default to recovery system.

This commit also adds a new docs page devoted to grub configuration.
Finally in also moves the wiki page devoted to a K3s and Fleet
deployment example into its own docs page.

Signed-off-by: David Cassany <[email protected]>
This commit refactors the tests to make use of `grub2-editenv` utility
to configure the default grub boot entry.

Signed-off-by: David Cassany <[email protected]>
@Itxaka
Copy link
Contributor

Itxaka commented Jul 8, 2021

All tests green, nice change!

@mudler mudler enabled auto-merge (squash) July 8, 2021 09:29
@davidcassany
Copy link
Contributor Author

davidcassany commented Jul 8, 2021

All tests green, nice change!

Yes, test-recovery had some issues. In fact, I do have concerns about these tests, since we can't get back to the initial state in any way after running cos-upgrade --recovery ..., if we had a way to cos-upgrade --docker-image <img-build-in-opensuse-build> then we could make these tests less error prone.

@Itxaka
Copy link
Contributor

Itxaka commented Jul 8, 2021

mmmhhh, we maybe be able to get away with mounting a temporal dir from the runner into the vm, but that would imply doing a create-repo with --type docker first and dumping the images into the runner so they are available. Possible but cumbersome.

Or we could rework the serial port stuff so it saves in different files using timestamp and then restore the snapshot functionality, so we get a pristine vm after each test... this seems simpler

@mudler
Copy link
Contributor

mudler commented Jul 8, 2021

mmmhhh, we maybe be able to get away with mounting a temporal dir from the runner into the vm, but that would imply doing a create-repo with --type docker first and dumping the images into the runner so they are available. Possible but cumbersome.

Or we could rework the serial port stuff so it saves in different files using timestamp and then restore the snapshot functionality, so we get a pristine vm after each test... this seems simpler

We could also avoid the docker repo type for tests, and just start an http server on the host (there is a small one embedded in luet for that purpose, luet serve-repo) we are already passing the whole repo between the artifacts. But I'd keep that for few tests, as testing with docker images has its own value as well

@davidcassany
Copy link
Contributor Author

We could also avoid the docker repo type for tests, and just start an http server on the host (there is a small one embedded in luet for that purpose, luet serve-repo) we are already passing the whole repo between the artifacts. But I'd keep that for few tests, as testing with docker images has its own value as well

That's a nice option indeed.

@mudler mudler merged commit e8dbf25 into master Jul 8, 2021
@mudler mudler deleted the use_grub_environment_block branch July 8, 2021 10:07
frelon pushed a commit to frelon/elemental-toolkit that referenced this pull request May 12, 2023
This commit sets the temp dir for luet on start up.

It also fixes a bug on partitions detection, where the device name
was used instead of the partition label. In elemental-cli partition
names are partition labels, they are hardcoded and not configurable.

Finally fixes few log messages

Fixes rancher#380

Signed-off-by: David Cassany <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants