fix: boot entry detection

Fixes: #13080

Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
Noel Georgi 2026-04-18 12:20:27 +05:30
parent 5e3f301887
commit 509cd97339
No known key found for this signature in database
GPG Key ID: 21A9F444075C9E36
2 changed files with 16 additions and 4 deletions

View File

@ -55,7 +55,7 @@ func (ctrl *BootedEntryController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
func (ctrl *BootedEntryController) Run(ctx context.Context, r controller.Runtime, _ *zap.Logger) error {
func (ctrl *BootedEntryController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
// If we're booted in Container mode, short-circuit the controller.
if ctrl.V1Alpha1Mode == machineruntime.ModeContainer {
return nil
@ -114,10 +114,16 @@ func (ctrl *BootedEntryController) Run(ctx context.Context, r controller.Runtime
// Ref: https://cateee.net/lkddb/web-lkddb/EFI_BOOTLOADER_CONTROL.html
case loaderEntryRebootReason == "reboot" && loaderEntryOneShot == "kexec reboot":
if loaderEntryDefault == "" {
return fmt.Errorf("LoaderEntryDefault variable is empty, cannot determine booted entry")
}
logger.Warn("LoaderEntryDefault variable is empty, falling back to LoaderEntrySelected variable to determine booted entry")
bootedEntry = loaderEntryDefault
if loaderEntrySelected == "" {
return fmt.Errorf("LoaderEntrySelected variable is empty, cannot determine booted entry")
}
bootedEntry = loaderEntrySelected
} else {
bootedEntry = loaderEntryDefault
}
// this case is when we have a `LoaderEntryDefault` set by the installer and during a reboot the user selected
// a different entry, so we set the `LoaderEntrySelected` as the booted entry
// we can use this information later to decide which UKI's to clean up

View File

@ -63,6 +63,12 @@ func (suite *UKISuite) TestUKIBooted() {
asrt.True(r.TypedSpec().BootedWithUKI)
},
)
rtestutils.AssertResources(ctx, suite.T(), suite.Client.COSI, []resource.ID{runtimeres.BootedEntryID},
func(r *runtimeres.BootedEntry, asrt *assert.Assertions) {
asrt.NotEmpty(r.TypedSpec().BootedEntry, "BootedEntry should not be empty when booted with UKI")
},
)
}
func init() {