Skip to content

Conversation

igoropaniuk
Copy link
Contributor

@igoropaniuk igoropaniuk commented Sep 19, 2024

Add support for boot counting for bootloader entries [1].
The boot counting data is stored in the name of the boot loader entry.
A boot loader entry file name may contain a plus (+) followed by a number.
This may optionally be followed by a minus (-) followed by a second number.
The dot (.) and file name suffix (conf or efi) must immediately follow.

The feature is enabled via sysroot configuration:
[sysroot]
boot-counting-tries=3

Testing:
$ ostree admin deploy 91fc19319be9e79d07159303dff125f40f10e5c25614630dcbed23d95e36f907
Copying /etc changes: 2 modified, 3 removed, 4 added
bootfs is sufficient for calculated new size: 0 bytes
Transaction complete; bootconfig swap: yes; bootversion: boot.0.1, deployment count change: 1

$ ls /boot/loader/entries
ostree-1.conf ostree-2+3.conf

[1] https://uapi-group.org/specifications/specs/boot_loader_specification/#boot-counting

Copy link

openshift-ci bot commented Sep 19, 2024

Hi @igoropaniuk. Thanks for your PR.

I'm waiting for a ostreedev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@igoropaniuk
Copy link
Contributor Author

This PR was created for initial feedback, I'll address the naming in the tests if needed and re-push

@cgwalters
Copy link
Member

I love the idea of integrating here, thanks for starting this! This came up before in at least #3032

Hmm don't we need to consider how we make this configurable? Currently systemd kernel-install parses /etc/kernel/tries. (I think we should also support a /usr/lib variant of this, but that's mostly an aside). I guess we could in theory just start honoring that file too?

@igoropaniuk
Copy link
Contributor Author

igoropaniuk commented Sep 23, 2024

@cgwalters thanks for the feedback, my concern regarding parsing /etc/kernel/tries is that it's systemd-specific config, which is not described in https://uapi-group.org/specifications/specs/boot_loader_specification/

A can add an optional autoconf flag for that

@igoropaniuk
Copy link
Contributor Author

igoropaniuk commented Oct 16, 2024

@cgwalters added support for /etc/kernel/tries as suggested
I also wrapped the functionality with an autoconf flag (--enable-boot-count), which is disabled by default.

@igoropaniuk igoropaniuk changed the title [RFC] sysroot: Support boot counting for boot entries sysroot: Support boot counting for boot entries Oct 16, 2024
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Thanks so much for working on this!

@cgwalters
Copy link
Member

BTW, which bootloader are you looking at using this with?

@igoropaniuk
Copy link
Contributor Author

@cgwalters EDK2 + systemd-boot

@igoropaniuk
Copy link
Contributor Author

@cgwalters I've addressed all comments, thanks!

@igoropaniuk
Copy link
Contributor Author

@cgwalters looks like some CI tests are still failing, but all of them are unrelated to this change, for example:

2024-10-30T16:06:09.9538403Z ERROR: tests/test-commit-sign.sh - too few tests run (expected 7, got 2)
2024-10-30T16:06:09.9539247Z ERROR: tests/test-commit-sign.sh - exited with status 1

@igoropaniuk igoropaniuk requested a review from cgwalters October 31, 2024 13:50
@cgwalters
Copy link
Member

Yes CI failures are unrelated, will look at this soon

@igoropaniuk
Copy link
Contributor Author

The PR is not stalled, I'll get back to it tomorrow

@igoropaniuk igoropaniuk force-pushed the boot_count branch 2 times, most recently from 030b79c to 8802316 Compare December 4, 2024 22:16
@igoropaniuk igoropaniuk requested a review from jlebon December 4, 2024 22:18
@igoropaniuk
Copy link
Contributor Author

@jlebon @cgwalters all comments addressed, please take a look

@igoropaniuk igoropaniuk force-pushed the boot_count branch 2 times, most recently from 905317a to 9ab2679 Compare December 4, 2024 22:21
@igoropaniuk igoropaniuk force-pushed the boot_count branch 3 times, most recently from 37ba251 to 087e056 Compare December 5, 2024 21:15
@igoropaniuk igoropaniuk force-pushed the boot_count branch 2 times, most recently from dfd586a to 6362318 Compare May 14, 2025 16:23
@igoropaniuk
Copy link
Contributor Author

@cgwalters Apologies for the delay. I've addressed all the comments except the last one concerning the "usage" variable.

Could we get this PR to land first (as it seems closer to being merged in terms of its maturity), and then I'll focus on addressing all issues in the other one (#3310) afterwards?

@igoropaniuk igoropaniuk requested a review from cgwalters June 18, 2025 10:28
@cgwalters
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for boot counting for bootloader entries, aligning with the Boot Loader Specification. The changes are comprehensive, touching on API documentation, configuration parsing, and bootloader entry filename generation. The implementation is mostly solid, but I've found a few issues, including a critical bug in the boot counter parsing logic and a discrepancy in the configuration handling for boot-counting-tries. I've also pointed out some minor documentation and code style issues. Once these are addressed, the PR should be in good shape.

@cgwalters
Copy link
Member

OK I

  • Addressed the gemini review comments
  • Added unit tests for the tries parsing
  • Added a unit-admin test that verifies we write the bootloader entry files w/boot counting initalized

@cgwalters
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for boot counting for bootloader entries, following the Boot Loader Specification. The implementation includes parsing the boot count from filenames, configuring the number of tries, and generating appropriate bootloader entry filenames. The changes are well-structured and include documentation and tests.

My main feedback is on the boot counter parsing logic in ostree-bootconfig-parser.c, which appears to be more lenient than the specification and contains a minor bug. I've left detailed comments on this. I've also pointed out a minor documentation issue in the same file.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Forgot to also mention I went ahead and rebased this on git main.

I have just a few other minor comments but I think we can get this in by tomorrow - what do you think?

@igoropaniuk igoropaniuk force-pushed the boot_count branch 3 times, most recently from 8b16858 to 21866a9 Compare July 9, 2025 21:30
@cgwalters
Copy link
Member

OK I pushed more changes to resolve review comments

@igoropaniuk
Copy link
Contributor Author

igoropaniuk commented Jul 9, 2025

@cgwalters, it seems we are simultaneously working to address comments :)
Would you like me to finish addressing all the issues, or would you like to handle that on your own?

@cgwalters
Copy link
Member

@cgwalters, it seems we are simultaneously working to address comments :)

Ahhh sorry! Based on your location I thought you'd be sleeping now 😄

OK I did just one more force push but I will hand over the PR to you! What do you think of the changes?

@igoropaniuk
Copy link
Contributor Author

igoropaniuk commented Jul 9, 2025

@cgwalters

Ahhh sorry! Based on your location I thought you'd be sleeping now 😄
OK I did just one more force push but I will hand over the PR to you! What do you think of the changes?

Great, thanks for covering this functionality with unit tests and addressing the reported issues by Gemini!
Please let me know if you have any additional comments; I'll review them tomorrow morning and try to address them right away + address build issues reported by CI as well (so everything is ready when you return to this PR)

@cgwalters
Copy link
Member

Offhand I don't have any other issues!

It looks like I broke CI by adding ostree_bootconfig_parser_get_tries_done to public API without also listing it in apidoc/ - that should be an easy fix.

@cgwalters cgwalters mentioned this pull request Jul 9, 2025
33 tasks
Add support for boot counting for bootloader entries [1].
The boot counting data is stored in the name of the boot loader entry.
A boot loader entry file name may contain a plus (+) followed by a number.
This may optionally be followed by a minus (-) followed by a second number.
The dot (.) and file name suffix (conf or efi) must immediately follow.

The feature is enabled via sysroot configuration:
[sysroot]
boot-counting-tries=3

Testing:
$ ostree admin deploy 91fc19319be9e79d07159303dff125f40f10e5c25614630dcbed23d95e36f907
Copying /etc changes: 2 modified, 3 removed, 4 added
bootfs is sufficient for calculated new size: 0 bytes
Transaction complete; bootconfig swap: yes; bootversion: boot.0.1, deployment count change: 1

$ ls /boot/loader/entries
ostree-1.conf  ostree-2+3.conf

[1] https://uapi-group.org/specifications/specs/boot_loader_specification/#boot-counting
Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Signed-off-by: Colin Walters <walters@verbum.org>
@igoropaniuk
Copy link
Contributor Author

It looks like I broke CI by adding ostree_bootconfig_parser_get_tries_done to public API without also listing it in apidoc/ - that should be an easy fix.

Fixed, thanks for the hint!

@cgwalters
Copy link
Member

/override ci/prow/fcos-e2e
I'll probably drop this one as it's always duplicated coreos ci jenkins

Copy link

openshift-ci bot commented Jul 10, 2025

@cgwalters: Overrode contexts on behalf of cgwalters: ci/prow/fcos-e2e

In response to this:

/override ci/prow/fcos-e2e
I'll probably drop this one as it's always duplicated coreos ci jenkins

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@cgwalters cgwalters merged commit f4bc422 into ostreedev:main Jul 10, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants