Skip to content

Commit

Permalink
fix: properly halt installation if Talos already installed
Browse files Browse the repository at this point in the history
Do not return from the function unless ctx is canceled.

Signed-off-by: Dmitriy Matrenichev <[email protected]>
  • Loading branch information
DmitriyMV committed Nov 26, 2024
1 parent 177df62 commit f1d1628
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1603,21 +1603,23 @@ func SaveStateEncryptionConfig(runtime.Sequence, any) (runtime.TaskExecutionFunc
}

// haltIfInstalled halts the boot process if Talos is installed to disk but booted from ISO.
func haltIfInstalled(seq runtime.Sequence, _ any) (runtime.TaskExecutionFunc, string) {
func haltIfInstalled(runtime.Sequence, any) (runtime.TaskExecutionFunc, string) {
return func(ctx context.Context, logger *log.Logger, r runtime.Runtime) error {
ctx, cancel := context.WithTimeout(ctx, constants.BootTimeout)
defer cancel()

timer := time.NewTicker(30 * time.Second)
defer timer.Stop()

select {
case <-timer.C:
for {
logger.Printf("Talos is already installed to disk but booted from another media and %s kernel parameter is set. Please reboot from the disk.", constants.KernelParamHaltIfInstalled)
case <-ctx.Done():
}

return nil
select {
case <-timer.C:
case <-ctx.Done():
return ctx.Err()
}
}
}, "haltIfInstalled"
}

Expand Down

0 comments on commit f1d1628

Please sign in to comment.