diff --git a/internal/app/machined/pkg/controllers/runtime/booted_entry.go b/internal/app/machined/pkg/controllers/runtime/booted_entry.go index c29b84cb1..52764ef7b 100644 --- a/internal/app/machined/pkg/controllers/runtime/booted_entry.go +++ b/internal/app/machined/pkg/controllers/runtime/booted_entry.go @@ -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 diff --git a/internal/integration/api/uki.go b/internal/integration/api/uki.go index 9857b8b47..57824b95c 100644 --- a/internal/integration/api/uki.go +++ b/internal/integration/api/uki.go @@ -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() {