Add timeout wait for sysroot (#278)

This commit is contained in:
Itxaka
2024-04-09 08:40:28 +00:00
committed by GitHub
parent b4654ffb47
commit b9fe50bf84
2 changed files with 16 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"time"
cnst "github.com/kairos-io/immucore/internal/constants"
@@ -119,7 +120,18 @@ func (s *State) MountRootDagStep(g *herd.Graph) error {
func (s *State) WaitForSysrootDagStep(g *herd.Graph) error {
return g.Add(cnst.OpWaitForSysroot,
herd.WithCallback(func(ctx context.Context) error {
cc := time.After(60 * time.Second)
var timeout = 60 * time.Second
timeoutArg := internalUtils.CleanupSlice(internalUtils.ReadCMDLineArg("rd.immucore.sysrootwait="))
if len(timeoutArg) > 0 {
atoi, err := strconv.Atoi(timeoutArg[0])
if err == nil && atoi > 0 {
timeout = time.Duration(atoi) * time.Second
}
}
internalUtils.Log.Debug().Str("timeout", timeout.String()).Msg("Waiting for sysroot")
cc := time.After(timeout)
for {
select {
default: