boot/grub.go: add new bootchain#13412
Conversation
d8a8354 to
e576bcc
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #13412 +/- ##
=========================================
Coverage 78.88% 78.88%
=========================================
Files 1037 1040 +3
Lines 132757 133944 +1187
=========================================
+ Hits 104722 105668 +946
- Misses 21503 21675 +172
- Partials 6532 6601 +69
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Needed for #13205 |
|
I have found a bug. We do not seem to remove files that should be removed. So moving from boot entry back to non boot entry (that is removing the I wonder if we should add "removed" content to the gadget.yaml. |
pedronis
left a comment
There was a problem hiding this comment.
did a pass, I'm slightly wary of the changes to assets.go
207b4f2 to
5401330
Compare
759e5d3 to
5d9a30b
Compare
5d9a30b to
3188a4c
Compare
|
I had to rebase. So I cleaned up the history. |
pedronis
left a comment
There was a problem hiding this comment.
thank you, mainly some comments/questions about using Ids as Paths in BootFiles
There was a problem hiding this comment.
is this not supported? will it be?
There was a problem hiding this comment.
Oh! I am missing a fixme here.
I need to fix the deletion of gadget content that is not available in the next gadget. In case of downgrade, the "next gadget" should not have "fbx64.efi", so we should remove it, because it changes the behavior of shim.
I will do this fix in a different PR. But I will for sure comment here on why this does not work. And why it needs to work.
There was a problem hiding this comment.
I have added the explanation.
There was a problem hiding this comment.
this is a bit strange given that BootFile has a still a field called Path, I thought we would keep the path as they were and use the TrustedAssets map to get to id to use in the cache
There was a problem hiding this comment.
Thank you for the tip. I did not realize I could do that. I have fixed it.
There was a problem hiding this comment.
the comment should go away or be changed now
There was a problem hiding this comment.
why the []string? assetNames are now unique again and have one asset assigned to them?
There was a problem hiding this comment.
I was verifying that we had only one later. But now I have rewritten it so that we verify it right away.
There was a problem hiding this comment.
buildBootAssets could take the TrustedAssets map and then BootFile could still carry paths?
|
@olivercalder I have added you as reviewer. This has some changes from your branch to add the new boot chain. But it does not do anything with the variables yet. I will rebase your branch on top of this. I thought you would like to have a look. |
pedronis
left a comment
There was a problem hiding this comment.
thank you, some detail comments on the last round of changes
There was a problem hiding this comment.
the comment should go away or be changed now
There was a problem hiding this comment.
should we call this ...AllBootChains to clarify what is about a bit more?
There was a problem hiding this comment.
This tests the internal function runModeBootChains. This is why I named it like that. Function recoveryBootChainsForSystems is already tested by TestRecoveryBootChainsForSystems. And we were missing tests for runModeBootChains. Not sure what to name it if not TestRunModeBootChains.
There was a problem hiding this comment.
I see, do have higher level tests then that test the case where we need to consider both old and new grub assets locations? I saw only this one doing that but maybe I missed them
There was a problem hiding this comment.
Right, I think we are missing a test for ResealKeyToModeenv with both chain present at the same time. We do test both. But separately.
There was a problem hiding this comment.
I have modified TestResealKeyToModeenvWithSystemFallback to also cover cases where we upgrade or downgrade. This calls ResealKeyToModeenv which is higher level.
But that is starting to be complicated. Specially because of ordering and factorization of boot chains. There is lots of ways to express allowed boot chains. But we only test one, which is very hard to guess. I spend a day to make it work.
There was a problem hiding this comment.
we probably want to keep this comment before the log below?
There was a problem hiding this comment.
Not all trusted assets will be present now. So I am thinking we should remove the notice. But the logic is still fine. If the asset is not in the cache, then we should ignore it.
There was a problem hiding this comment.
this is strange, it should either be a log or a panic, no?
There was a problem hiding this comment.
That was some debugging that I committed by mistake.
There was a problem hiding this comment.
thank you, looking good, just some remarks about comments and a question about the test combinations #13412 (comment)
There was a problem hiding this comment.
s/names in/names recorded in/ is perhaps slightly clearer?
There was a problem hiding this comment.
s/names in/names recorded in/
There was a problem hiding this comment.
this probably merit a comment why the new logic is ok with not finding some asset chains
There was a problem hiding this comment.
This one can only be generated by a broken bootloader. So it should be an error.
alfonsosanchezbeato
left a comment
There was a problem hiding this comment.
I have a question about the spread test
There was a problem hiding this comment.
Shouldn't this work by removing the content of the EFI boot vars, as a temporary workaround? Or by removing the files under EFI/ubuntu/.
There was a problem hiding this comment.
Well, we do not touch variables in this PR. This will come in the Oliver's PR. It is better to remove EFI/ubuntu and EFI/boot/fbx64.efi. If the variables are wrong, it will fallback anyway. But this is what I want installation of gadget to do. A "content" entry that disappears should imply removing the file.
There was a problem hiding this comment.
But maybe still worth running this part of the test by removing "manually" the files, even while keeping the comment so when removing from snapd is implemented we can remove the workaround?
There was a problem hiding this comment.
I will try preventing reboot with systemd-inhibit and see if I can remove the assets before reboot.
There was a problem hiding this comment.
Right, it is true that being faster than the reboot can be a problem, so please ignore this if it gets too hacky. Approving now, thanks for the changes.
There was a problem hiding this comment.
Nice! Maybe the comment above need to be slightly adapted now explaining the workaround.
There was a problem hiding this comment.
super-nitpick: 2024 now 🙂
There was a problem hiding this comment.
typo: s/the list load chains/the list of load chains/
pedronis
left a comment
There was a problem hiding this comment.
thank you, small issue with the error message also there seem to be formatting issues as the static checks are failing
There was a problem hiding this comment.
s/Asset/internal error: asset/ error always start with lowercase
olivercalder
left a comment
There was a problem hiding this comment.
Looks really good, thank you!
There was a problem hiding this comment.
I don't believe relativeTarget is used anymore in this function?
There was a problem hiding this comment.
Correct. Not easy to spot. I have removed it.
There was a problem hiding this comment.
I think a comment here would be very useful to explain if it is expected behavior that there are multiple assets of the same name, and if not, why we use byAssetName instead of trustedAssets in the latter for loop. It seems to me that constructing and using byAssetName guarantees there are no reused asset names and is thus safer, but a comment to this effect would be useful. Something like "same as trustedAssets, but with uniqueness guarantee"
There was a problem hiding this comment.
I changed this multiple times. So it seems in the end it was just about filtering duplicates. I will simplify the code here.
There was a problem hiding this comment.
I have simplified the code.
There was a problem hiding this comment.
I can't seem to find where TrustedAssetsList is actually defined outside of mocking, but perhaps s/TrustedAssetsList/TrustedAssetsMap/g, since it's now a map instead of a list?
There was a problem hiding this comment.
Changed it and all the tests to use a map.
There was a problem hiding this comment.
Yes, I should may comment on it. The idea about using "asset names" instead of the path is because current implementation uses base names. So for backward compliance, we need to use no tag for all the paths that were used before. I will comment it.
There was a problem hiding this comment.
Ah now I understand. fb was not an old one. I can put boot: for this one.
7c253df to
d6db7d9
Compare
pedronis
left a comment
There was a problem hiding this comment.
thank you, one wondering
There was a problem hiding this comment.
I wonder as we are very much in control of this from the bootloader side, whether this should be an actual error? cc @alfonsosanchezbeato @bboozzoo
There was a problem hiding this comment.
Probably this should return as an internal error, I agree
olivercalder
left a comment
There was a problem hiding this comment.
Looks great, thanks for taking on all of this!
|
Everything should be fixed. I will let the CI run and then autosquash it. |
We need to resolve the boot chains another place based on the trusted assets we encountered to be installed. At this point it could be any chain. We will need to discover later what the correct chain is. Also make TrustedAssets return an unsorted data structure to make sure we do not use the order like the comments claimed.
25b4ef9 to
95b2edb
Compare
We need to resolve the boot chains another place based on the trusted assets we encountered to be installed. At this point it could be any chain. We will need to discover later what the correct chain is.
Also make TrustedAssets return an unsorted data structure to make sure we do not use the order like the comments claimed.